// Demo: This is the wrong way to // : update the name,id,class // : by entering directly in the main program // #include #include #include using namespace std; class Student { private: string id,name,class_no; public: Student(){ id="id00"; name="none"; class_no="00"; } // initial values given for very student void show() { cout << left << setw(5) << id << setw(15) << name << class_no << endl; } void enter(); // update name only }; void Student::enter() { // updates name, but not id and class_no cout << "enter name "; getline(cin,name); } void main() { Student x,y; // create 2 students x and y string name,id,class_no; x.show(); // display student x"id00 none 00" // enter name,id,class_no cout << "enter id " ; getline(cin,id); // enter A123 cout << "enter name "; getline(cin,name); // enter TAN cout << "enter class no "; getline (cin,class_no); // enter 44 x.show(); // display "id00 mone 00" for student x. NOT UPDATED } /* output when program is runned id00 none 00 id A123 name TAN class no 44 id00 none 00 */