Create a class in C++ name Height with the following Data members
• Feet
• Inches
The Height class presents Height in Feet and Inches. For instance, Height (4, 3) means 4 feet and 3 inches. The Height class you will design should have the following features.
Constructors
Class must have
1. Default constructor, which must set Feet and Inches to zero.
2. Parameterized constructor that receives one parameter of type int (that will be height in form of inches) converts the arguments into feet and inches and initializes its private data: feet and inches with them.
3. Parameterized constructor that receives two parameter of type int initializes its private data: feet and inches with them. Note that if inches are 12 or greater than 12 then also convert it in feet.
Member functions
Create a class in C++ name Height with the following Data members?
What do you want us to do? The question has pretty much given you all the clues you need to do this exercise. If you're actually studying C++ and have been given this as homework, you should have a go at it yourself. If you can't, or don't want to, then I'd be asking why you're doing this course in the first place.
Note: Programming is not for everyone. People who survive in this industry are (a) hard working, (b) have SOME ability to think logically and (c) are able to look things up and learn new stuff.
Reply:Class Height {
double feet;
double inches;
.
.
.
};
Reply:class Height
{
private:
int Feet;
int Inches;
public:
//constructors of class
Height();
Height(int,int);
int setfeet();
int setinches();
int getfeet();
int getinches();
void display();
~Height();
};
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment