Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students explore these related Databases questions

Question

Understand how emergent change occurs.

Answered: 3 weeks ago