|
From: <Tre...@ao...> - 2001-07-30 18:32:11
|
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.
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
date on the screen.
#include <iostream>
using namespace std;
class Date
{
public:
Date();
int assignDate(int, int, int);
void displayDate();
private:
int month;
int day;
int year;
};
Date::Date()
{
month = 0;
day = 0;
year = 0;
} //end of default constructor
int Date::assignDate(int m, int d, int y)
{
month = m;
day = d;
year = y;
if (m >=1 && m <= 12)
{
if (m = 2)
if (y % 4 == 0)
if (d >= 1 && d <= 29)
{
return m;
return d;
return y;
}
else if (d >= 1 && d <= 28)
{
return m;
return d;
return y;
}
else if (m == 4 || m == 6 || m == 9 || m == 11)
if (d >= 1 && d <= 30)
{
return m;
return d;
return y;
}
else if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m ==
10 || m == 11)
if (d >= 1 && d <= 31)
{
return m;
return d;
return y;
}
}//end loop
else
cout << "Month does not exist" << endl;
//end ifs
} //end of assignDate function
void Date::displayDate()
{
cout << month << "/" << day << "/" << year;
} //end of displayDate function
|