can you help me solve this question? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can you help me solve this question?

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

8th Apr 2020, 6:25 AM
Ahmed Ba Haroon
Ahmed Ba Haroon - avatar
2 Answers
+ 3
Public setAge(a) int return
16th Jul 2022, 11:42 AM
Sanjay Leo
Sanjay Leo - avatar
0
In the Student constructor, you will want to pass 'a' to setAge() in order to properly initialize "age", i.e. setAge( a ); and getAge() should return an integer, namely "age", so its definition would be int getAge() { return age; }
8th Apr 2020, 7:15 AM
Shadow
Shadow - avatar