I have written a C++ class called 'Birthday' and I want to write a method that can compare with another Birthday object and return true if it is a later date and false otherwise. What am I supposed to but into the parameters/method and what would I call in my main function to compare these objects? Here is what I have so far: #include <iostream>#include <string>#include <sstream>using namespace std; class Birthday{private:int m_day;int m_month;string m_name;public:Birthday(){}Birthday(int month, int day, string name){m_month = month;m_day = day;m_name = name;}int getMonth(){return m_month;}bool isLater() //this is the method I am trying to write{if (m_month){return true;}else}string toString(){stringstream stream;stream << m_month << "/" << m_day << ": " << m_name;return stream.str();} }; int main(int argc, char* argv[]) { //main method Birthday(); return 0; }
I have written a C++ class called 'Birthday' and I want to write a method that can compare with another Birthday object and return true if it is a later date and false otherwise. What am I supposed to but into the parameters/method and what would I call in my main function to compare these objects? Here is what I have so far:
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class Birthday
{
private:
int m_day;
int m_month;
string m_name;
public:
Birthday()
{
}
Birthday(int month, int day, string name)
{
m_month = month;
m_day = day;
m_name = name;
}
int getMonth()
{
return m_month;
}
bool isLater() //this is the method I am trying to write
{
if (m_month)
{
return true;
}
else
}
string toString()
{
stringstream stream;
stream << m_month << "/" << m_day << ": " << m_name;
return stream.str();
}
};
int main(int argc, char* argv[]) { //main method
Birthday();
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images