|
From: Ioannis V. <no...@ya...> - 2001-07-30 18:43:00
|
<http://run.to/noicys>=20 -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Tre...@ao... Sent: Monday, July 30, 2001 8:32 PM To: dev...@li... Subject: [Dev-C++] Class question I am learning how to create a class and I need help. After creating the class and compiling my program I get the following error.=20 warning C4715: 'Date::assignDate' : not all control paths return a value This is my class. It is supposed to validate a date entered and display the=20 date on the screen. =20 #include <iostream>=20 using namespace std;=20 class Date=20 {=20 public:=20 Date();=20 int assignDate(int, int, int);=20 void displayDate();=20 private:=20 int month;=20 int day;=20 int year;=20 };=20 Date::Date()=20 {=20 month =3D 0;=20 day =3D 0;=20 year =3D 0;=20 } //end of default constructor=20 int Date::assignDate(int m, int d, int y)=20 {=20 month =3D m;=20 day =3D d;=20 year =3D y;=20 if (m >=3D1 && m <=3D 12)=20 {=20 if (m =3D 2)=20 if (y % 4 =3D=3D 0)=20 if (d >=3D 1 && d <=3D 29)=20 {=20 return m;=20 return d;=20 return y;=20 }=20 else if (d >=3D 1 && d <=3D 28)=20 { =20 return m;=20 return d;=20 return y;=20 }=20 else if (m =3D=3D 4 || m =3D=3D 6 || m =3D=3D 9 || m =3D=3D 11)=20 if (d >=3D 1 && d <=3D 30)=20 {=20 return m;=20 =20 These 2 are not returned. return d; =20 return y;=20 }=20 else if (m =3D=3D 1 || m =3D=3D 3 || m =3D=3D 5 || m =3D=3D 7 || m = =3D=3D 8 || m =3D=3D=20 10 || m =3D=3D 11)=20 if (d >=3D 1 && d <=3D 31)=20 {=20 return m; =20 =20 These 2 are not returned. return d;=20 return y;=20 }=20 }//end loop=20 else=20 cout << "Month does not exist" << endl;=20 //end ifs=20 } //end of assignDate function=20 void Date::displayDate()=20 {=20 cout << month << "/" << day << "/" << year;=20 } //end of displayDate function =20 =20 There are probably more errors too, but fix them first. =20 * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com <http://www.noicys.f2s.com/>=20 * Alternative URL: http://run.to/noicys =20 |