implementation for the InternPhone constructor and provide an implementation for the InternPhone Write(). Attached is the below code I wrote earlier with the InterPhone and Write() constructor.
I need to provide an implementation for the InternPhone constructor and provide an implementation for the InternPhone Write(). Attached is the below code I wrote earlier with the InterPhone and Write() constructor.
#include <iostream>
using namespace std;
enum PhoneType { HOME, OFFICE, CELL };
class Phone {
private:
int areaCode;
int number;
PhoneType type;
public:
Phone(int newAreaCode, int newNumber, PhoneType newType);
void Write();
};
Phone::Phone(int newAreaCode, int newNumber, PhoneType newType) {
areaCode = newAreaCode;
newNumber = newNumber;
type = newType;
}
void Phone::Write() {
cout << "Area code : " << areaCode << endl;
cout << "Number : " << number << endl;
cout << "Phone type : " << type << endl;
}
class internPhone :public Phone {
private:
int countrycode;
public:
internPhone(int newCountryCode, int newareaCode, int newNumber, PhoneType newType);
void write();
};
internPhone::internPhone(int newCountryCode, int newareaCode, int newNumber, PhoneType newType) :Phone(newareaCode, newNumber, newType) {
countrycode = newCountryCode;
}
void internPhone::write() {
cout << "Country Code :" << countrycode << endl;
Phone::Write();
}
int main()
{
internPhone ip(+1, 615, 2156584, OFFICE);
ip.write();
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images