Answer to Question #308619 in C++ for malav

Question #308619

assign and print the roll number,phone number,and address of two students having name sam and john respectively by creating two objects of the class student



1
Expert's answer
2022-03-09T12:32:23-0500

Here's how I implemented this program:

class Student
{
public:
	Student(string PhoneNumber, string RollNumber, string Adress)
	{
		this->PhoneNumber = PhoneNumber;
		this->RollNumber = RollNumber;
		this->Adress = Adress;
	}
	void Print()
	{
		cout << "Phone number: " << PhoneNumber << endl;
		cout << "Roll number: " << RollNumber << endl;
		cout << "Adress: " << Adress << endl;
	}
private:
	string PhoneNumber;
	string RollNumber;
	string Adress;
};

int main()
{
	Student Sem("+1(444) 444 444 4 ", "34353525", "West 95th St");
	Student Jonn("+1(888) 888 888 8 ", "64636464", "Western Ave");
	Sem.Print();
	cout << endl;
	Jonn.Print();
}

Everything should work, I checked.


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