I need help. Here is the homework problem:
Write the definitions of the functions to implement the operators defined for the class dateType.
Here's my code:
Header:
#ifndef dateSType_H
#define dateSType_H
//dateType name changed to dateSType
class dateSType
{
public:
// ************ Mutators follow ************
void setMM(int month);
//Function to set the month.
//The data members dMonth is set
//according to the parameters.
//Postcondition: dMonth = month;
// default month = 01
void setDD( int day );
//Function to set the month.
//The data members dDay is set
//according to the parameters.
//Postcondition: dDay = day;
// default day = 01
void setYY( int year);
//Function to set the month.
//The data members dYear is set
//according to the parameters.
//Postcondition: dYear = year;
// default day = 1900
void setDate(int month, int day, int year);
//Function to set the date.
//The data members dMonth, dDay, and dYear are set
//according to the parameters.
//Postcondition: dMonth = month; dDay = day;
// dYear = year default 1900
// default month = 01
//int getDay() const;
//Function to return the day.
//Postcondition: The value of dDay is returned.
//int getMonth() const;
//Function to return the month.
//Postcondition: The value of dMonth is returned.
//int getYear() const;
//Function to return the year.
//Postcondition: The value of dYear is returned.
void printDate() const;
//Function to output the date in the form mm-dd-yyyy.
dateSType();
//dateSType(int month = 1, int day = 1, int year = 1900);
//Constructor to set the date (Danger constructor here) #####
//The data members dMonth, dDay, and dYear are set
//according to the parameters.
//Postcondition: dMonth = month; dDay = day; dYear = year
//
//If no values are specified, the default values are
//used to initialize the data members.
private:
int dMonth; //variable to store the month
int dDay; //variable to store the day
int dYear; //variable to store the year
};
#endif
Implementation File:
dateSType::dateSType() { }
//default constructor
dateSType::dateSType(int, int, int) { }
//construct with parms
dateSType::~dateSType() {} //destructor
void dateSType::setDate(int month, int day, int year)
{
dMonth = month;
dDay = day;
dYear = year;
}
void setMM(int month)
{
if ((month > 0 ) && (month < 13))
dMonth = month; //valid month
else
dMonth = 1; //invalid month use default
}
Here are my errors:
1>------ Rebuild All started: Project: ch13homework_8, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'ch13homework_8', configuration 'Debug|Win32'
1>Compiling...
1>ImpL_Lab8.cpp
1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(1) : error C2653: 'dateSType' : is not a class or namespace name
1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(1) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(1) : warning C4508: 'dateSType' : function should return a value; 'void' return type assumed
1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(5) : error C2653: 'dateSType' : is not a class or namespace name
1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(5) : warning C4508: 'dateSType' : function should return a value; 'void' return type assumed
1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(8) : error C2653: 'dateSType' : is not a class or namespace name
1>c:\documents and settings\d2434login\desktop\impl_lab8.cpp(8) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>TestpgmLab8.cpp
1>Generating Code...
1>Build log was saved at "file://c:\Documents and Settings\d2434login\My Documents\Visual Studio 2005\Projects\ch13homework_8\ch13homework_8\Debug\BuildLog.htm"
1>ch13homework_8 - 6 error(s), 2 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Sorry for the long post and thanks in advance for the help.