my program

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166


//extra credit 

// Operator Overloading

#include <iostream>



using namespace 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
Last edited on
OPen it in notepad, then copy and paste it into your IDE.
Topic archived. No new replies allowed.