Answer to Question #297387 in C++ for Sonu

Question #297387

Create a class Address with house No., street name, city, and pincode as data T members. Use member functions to read and print the member values. Write a main method to demonstrate the Address class

1
Expert's answer
2022-02-13T13:00:34-0500




#include <iostream>
#include <string>
using namespace std;


class Address
{
private:
	int houseNo;
	string streetName;
	string city;
	int pincode;


public:


	void input(){
		cout << "Enter house No: ";
		cin >> houseNo;
		cin.ignore();
		cout << "Enter street name: ";
		getline(cin,streetName);
		cout << "Enter city: ";
		getline(cin,city);
		cout << "Enter pincode: ";
		cin>>pincode;
	}
	void dipslay()
	{
		cout << "\nAddress house No: "<<houseNo<<"\n";
		cout << "Address street name: "<<streetName<<"\n";
		cout << "Address city: "<<city<<"\n";
		cout << "Address pincode: "<<pincode<<"\n";
	}
};


int main()
{
	Address address;
	address.input();
	address.dipslay();
	cout<<"\n\n";
	system("pause");
	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