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
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.
Comments
Leave a comment