//extra credit
// Operator Overloading
#include <iostream>
usingnamespace std;
class Numdays { //beginning of class
private:
int days;
int hours;
void adjust_Numdays();
public:
Numdays(int d, int h);
Numdays(int h);
~Numdays() {};
int total_days();
void output();
Numdays operator+(Numdays a);
Numdays operator-(Numdays a);
};//end of class
Numdays::Numdays(int d, int h)
{//beginning of numdays
days = d;
hours = h;
adjust_Numdays();
}//end of numdays
Numdays::Numdays(int h)
{//beginning of num days for hours
hours = h;
days = 0;
adjust_Numdays();
}//end of numdays for hours
void Numdays::adjust_Numdays()
{//beginning of adjust numdays
while (hours >=24)
{
hours -=24;
days +=1;
}
}//end of adjust numdays
void Numdays::output()
{
cout<< days<< "days," << hours << "hours" <<endl;
}
int Numdays::total_days()
{
return ((hours + days*24)*3);
}
Numdays Numdays::operator+(Numdays a)
{
return Numdays(total_days() + a.total_days());
}
Numdays Numdays::operator-(Numdays a)
{
return Numdays(total_days() - a.total_days());
}
int main(void)
{
Numdays d(0);
d = d + Numdays(2, 12);
cout<<"After the first addition:"<<endl;
d.output();
cout <<"after addition";
d = d + 2;
d.output();
}
this code work before, i work in school copied it to hotmail.com and send it to myself. But when i get back home and copy and paste and run, it give me an error call "Mac file format detected: pelase convert the soiurce file to either DOS or UNIX format. that shouldn't be becuase the school computer are all windows and we use the exact same visual c++ 2008