Answer to Question #224704 in C++ for Somii

Question #224704
Write a class local phone that contains an attribute phone to store a local phone number. The class contains member functions to input and display phone number. Write a child class NatPhone for national phone numbers that inherits localPhone class .It additionally contains an attribute to store city code .. It also contains member function to input and show the city code. Write another class IntPhone for international phone numbers that inherits' Natphone class\.It additionally contains an attribute to store country code. It also contains member functions to input and show the country code. [01]
1
Expert's answer
2021-08-09T16:25:44-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS