0

Help me to find the error

#include using namespace std; class person { public:person(string n,int a , int i) : ID(i){ name=n; age=a; } person setname(string n){ name=n; return *this ; } person setage(int a){ age=a; return *this ; } string getname(){ return name ; } int getage(){ return age; } person print() const{ cout<<"the name is :"<<name<<endl; cout<<"the age is :"<<age<<endl; cout<<"the ID :"<<id<<endl; return *this; } private: string name ; int age; const int ID; }; int main(int argc, char** argv) { person te("dd",22,3); te.setage(11).setname("m3m3"); te.print(); person Me ("W",44,4); Me.setname("WW").setage(55); Me.print(); return 0; }

10th Nov 2020, 8:40 PM
Rawan
Rawan - avatar
3 Answers
+ 3
1. Check your #include statement 2. You have id in lowercase when it should be ID in the print() method.
10th Nov 2020, 8:55 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
GreatđŸ€© , thank you đŸ€
10th Nov 2020, 10:51 PM
Rawan
Rawan - avatar