Consider the class Person below.
class Person
{
public:
Person(string first_name, string last_name);
private:
string first_name;
string last_name;
};
a) Add the prototype definition of a member function that overloads the == operator.
b) Provide an implementation of the == operator so that a person is the same as another if their first and last names match.
Somewhat simple C++ programming question involving class?
Why don't you try it yourself? Operator overloading is pretty easy. If you run into trouble, we can help with specific problems.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment