I'm currently working on a school project and the requirements for part of the assignment I am working on looks like this:
The error state which the client can reference to determine if the object holds a valid date, and if not, which part of the date is in error. The possible error states are integer values defined as macros in the Date class header:
NO_ERROR 0 -- No error - the date is valid
CIN_FAILED 1 -- istream failed on information entry
YEAR_ERROR 2 -- Year value is invalid
MON_ERROR 3 -- Month value is invalid
DAY_ERROR 4 -- Day value is invalid"
And:
void errCode(int errorCode);
This function sets the error state variable to one of the values listed above.
However when I put my code into the second function visual studio gives me a red underline and states "expected an expression" when I try to use the macro values in an if statement.
// this code is unfinished and partial
void Date::errCode(int errorCode)
{
if (errorCode == NO_ERROR) // <- red underline here
{
m_errorState = NO_ERROR; // <- red underline here
}
if (errorCode == 1)
{
}
}
The header file defines look like this:
#define NO_ERROR = 0 // No error - the date is valid
#define CIN_FAILED = 1 // istream failed on information entry
#define YEAR_ERROR = 2 // Year value is invalid
#define MON_ERROR = 3 // Month value is invalid
#define DAY_ERROR = 4 // Day value is invalid