0

how to output in main()?

class Student{ private: int age; public: Student(int a){ setAge(a);} void setAge(int a){ age = a;} int getAge(){ return age;}};

13th Aug 2018, 2:58 PM
DarkEye
DarkEye - avatar
2 Answers
+ 2
DarkEye create object of class and call method as below : Student obj(21);//object created for a class cout << obj.getAge(); // get value of age using method call from object
13th Aug 2018, 3:15 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
thank you😁
13th Aug 2018, 3:32 PM
DarkEye
DarkEye - avatar