#include <iostream>
using namespace std;
class LocalPhone
{
private:
string phoneNumber;
public:
void inputNumber()
{
cout<<"Enter the local phone number\n";
cin >> phoneNumber;
}
void displayNumber()
{
inputNumber();
cout <<"The phone number entered is\t"<< phoneNumber<<endl;
}
};
class NatPhone : public LocalPhone
{
private:
string cityCode;
public:
void inputCityCode()
{
cout<<"Enter the city code\n";
cin >> cityCode;
}
void display()
{
displayNumber();
inputCityCode();
cout <<"The city code entered is \t"<< cityCode <<endl;
}
};
class IntPhone : public NatPhone
{
private:
string countryCode;
public:
void inputCountryCode()
{
cout<<"Enter the country code\n";
cin >> countryCode;
}
void display()
{
displayNumber();
inputCountryCode();
cout <<"The country code entered is \t"<< countryCode<<endl;
}
};
int main()
{
IntPhone phone;
phone.display();
return 0;
}
Comments
Leave a comment