>if (Date == someDate)
Date is a type, someDate is an object of that type. A comparison between them is nonsensical. I assume you want to test the parameter to see if it's the same object as the method is being called on?
bool Date::testEqual ( Date& someDate )
{
return this == &someDate;
}
>surely objects are treat the same as char, ints etc?
They can be made to be, but you still wouldn't do this even with built in types:
int i;
if ( int == i )
return true;
>but don't you have to write
No, either would work assuming the condition were correct:
if ( condition )
return true;
else
return false;
if ( condition )
return true;
// else
return false;
As long as the code after your conditional will never be executed if the condition is true, the whole construct is equivalent to an if..else statement.
However, if you're just returning or evaluating a boolean value, it's simpler to just use the condition itself rather than a conditional statement: