Create a class called Distance that has two data member feet as int type and inches as float type. Provide multiple constructors for the Distance class. One constructor should initialize this data to 0, and another should initialize it to fixed values. Also provide copy constructor to initialize Distance object with another object. Also provide get and set method for the class.
class Distance
{
int _feet;
float _inches;
public:
int GetFeet()
{
return _feet;
}
float GetInches()
{
return _inches;
}
void SetFeet(int feet)
{
_feet = feet;
}
void SetInches(float inches)
{
_inches = inches;
}
Distance()
{
_feet = 0;
_inches = 0;
}
Distance(int feet, float inches)
{
_feet = feet;
_inches = inches;
}
Distance(const Distance &distance)
{
_feet = distance._feet;
_inches = distance._inches;
}
};
Comments
Leave a comment