#include <iostream>
using namespace std;
class NumDays
{
private:
double hours;
double days;
public:
NumDays(double h=0)
{
hours=h;
}
how can I assign values to both hours and days, but only takes in the number of hours as its argument? I don't know how to assign the days without changing NumDays(double h=0)
void setHours(double h)
{
//code
}
how can I set function that assign values to both hours and days, but only takes in the number of hours as its argument?
double getHours() const
{
return hours;
}
void setDays(double d)
{
//code
}
how can I set function that assign values to both hours and days, but only takes in the number of hours as its argument?
double getDays() const
{
return days;
}
NumDays operator +(NumDays &);
NumDays operator ++();
NumDays operator (int);
};
int main()
{
NumDays dayOne(17), dayTwo(27),dayThree, dayFour, dayFive;
cout<< "Day One: "<< dayOne.getDays() << endl;
cout<< "Day Two: "<< dayTwo.getDays() << endl;
dayThree =dayOne +dayTwo;
cout<<"Day Three (in days): "<< dayThree.getDays() <<endl;
cout<<"Day Three (in hours): "<< dayThree.getHours() <<endl;
cout<<endl;
dayFour = dayThree++;
cout<<"Day Three (in days): "<< dayThree.getDays() <<endl;
cout<<"Day Three (in hours): "<< dayThree.getHours() <<endl;
cout<<"Day Four (in days): "<< dayFour.getDays() <<endl;
cout<<"Day Four (in hours): "<< dayFour.getHours() <<endl;
cout<< endl;
dayFive= ++dayThree;
cout<<"Day Three (in days): "<< dayThree.getDays() <<endl;
cout<<"Day Three (in hours): "<< dayThree.getHours() <<endl;
cout<<"Day Five (in days): "<< dayFive.getDays() <<endl;
cout<<"Day Five (in hours): "<< dayFive.getHours() <<endl;
cout<< endl;
system("pause");
return 0;
}