I'm writing a dayType class program and I'm having trouble with comparing two different days to each other. Here is what I have for them:

bool dayType::equalDay(const dayType& otherday) const
{

}

and here is main:

if (day.equalDay(newday))
   cout << " equal days" << endl;
else
    cout << "not equal days" << endl;

at this moment day and newday are both set to 29, so cout << " equal days" << endl; should be run, but I'm having a hard time figuring out how to write the statement to compare these two.

I would really appreciate and help offered.

Thanks for the help.

Sincerely yours;

jdm

bool dayType::equalDay(const dayType& otherday) const
{
    return (this->day == otherday.day);
}

"this" is the object with which you are calling equalDay().
You are comparing this's day and otherdays's day and returning the result.

Thank you for the help.

It worked perfectly.

jdm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.