Question: C++, use visual studio. I have code here but there is lots of error. #include using namespace std; // classs declaration class dateTpe { private:
C++, use visual studio. I have code here but there is lots of error.
#include using namespace std; // classs declaration class dateTpe { private: int dMonth; int dDay; int dYear; public: // memeber function declaration void setDate(int month, int day, int year); int getDay()const; int getMonth()const; int getYear()const; void printDate()const; bool isLeapYear(int year); dateType(int month=0, int day=0, int year=0); }; // member function definations void dateType::setDate(int month, int day, int year) { int noDyas; if (year <= 2008) { // condition to check wheather year is valid dYear = year; if (month <= 12) { // condition for month dMonth = month; switch (month) { // for number of days in each month case 1: case 3: case 5: case 7: case 8: case 10: case 12: noDays = 31; break; case 4: case 6: case 9: case 11: noDays = 31; break; case 2: if (isLeapYear(year)) noDays = 29; else noDays = 28; } if (day <= noDays) { // condition for dyas based on no of days in month dDay = day;
} else { cout << "Invalid Day" << endl; dDay = 0; }
} else { cout << "Invalid Month" << endl; dMonth = 0; }
} else { cout << "Invalid Year" << endl; dYear = 0;
} } bool dateType::isLeapYear(int year) { // function to confirm if (year % 4 == 0) return true; else return false;
} void dateType::printDate()const { cout << dMonth << "-" << dDay << "-" << dYear; }