Question
Need Help to wirte the code that will Overload the relational operators in the following code: #ifndef H_personType #define H_personType #include #include using namespace std;
Need Help to wirte the code that will Overload the relational operators in the following code:
#ifndef H_personType
#define H_personType
#include
#include
using namespace std;
class personType
{
//Overload the stream insertion and extraction operators.
friend istream& operator>>(istream&, personType&);
friend ostream& operator<<(ostream&, const personType&);
public:
const personType& operator=(const personType&);
//Overload the assignment operator.
void setName(string first, string last);
//Function to set firstName and lastName according to
//the parameters.
//Postcondition: firstName = first; lastName = last
string getFirstName() const;
//Function to return the first name.
//Postcondition: The value of firstName is returned.
string getLastName() const;
//Function to return the last name.
//Postcondition: The value of lastName is returned.
personType(string first = "", string last = "");
//constructor with parameters
//Set firstName and lastName according to the parameters.
//Postcondition: firstName = first; lastName = last
//Overload the relational operators.
bool operator==(const personType& right) const;
bool operator!=(const personType& right) const;
bool operator<=(const personType& right) const;
bool operator<(const personType& right) const;
bool operator>=(const personType& right) const;
bool operator>(const personType& right) const;
protected:
string firstName; //variable to store the first name
string lastName; //variable to store the last name
};
#endif
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started