Hi I'm a n00b at C++ and going through some past exam papers for practice and I finding difficulty with this question can anyone help me please.
The exam question is:
c) In this question we will develop a class for a telephone book.
i) Define a phone_number class containing a name of a person/company (as a
string) and a phone number (again as a string). Include a constructor and
appropriate selector methods.
My answer is:
#include <iostream>
#include <string>
using namespace std;
class Phone_number
{
public:
string name; //name of person/company
string phoneNumber; //phone number as string
Phone_number(string name_, string phoneNumber_) : name(name_), phoneNumber(phoneNumber_){};
//initializes the name and phone to argurments
Phone_number(Phone_number &p); // copy constructor.
/*This is a selector method to get the name.*/
string Phone_number::getName()
{
return name;
}
/*This is a selector method to get the phoneNumber.*/
string Phone_number::getNumber()
{
return phoneNumber;
}
};
I took selector method to mean accessor method was I right in doing so?
P.S. The question that follows on this one is confusing, can someone help me with understanding it, here it is.
ii) Write an appropriate overloading of the operator== for this class.