I am trying to implement a function sameMonth from a class to compare two user entered months.
My class is declared in a header file "Date.h":
#include <iostream>
using namespace std;
class Date
{
private:
string month;
int day;
int year;
public:
Date();
Date(string aMonth, int aDay, int aYear);
void setMonth(string month);
void setDay(int aDay);
void setYear(int aYear);
string getMonth();
int getDay();
int getYear();
void printDate();
bool sameMonth(string aMonth, string aMonth2);
};
The function sameMonth itself exists in another file "Date.cpp"
bool sameMonth(string aMonth, string aMonth2)
{
if (aMonth == aMonth2)
{
cout << "The two months entered are the same" << endl;
return true;
}
return false;
cout << "The two months are different" << endl;
}
The rest of the program is run from a "main.cpp" file. Here I am tying to compare the two months stored in two of my class objects. However, I cant seem to figure out exactly how to call the function.
Here is my attempt (code snippet).
bool testMonth;
Date compare;
testMonth = compare.sameMonth(aMonth, aMonth1);
Any suggestions?