We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Why do you need the variable count? I submitted the following code and it passed all 3 test cases (note : to have a better format of your code , start a line with 3 backticks ,then write your code , and at the last line type again 3 backtiks)
classPerson{public:intage;Person(intinitialAge);voidamIOld();voidyearPasses();};Person::Person(intinitialAge){if(initialAge>=0)age=initialAge;else{cout<<"Age is not valid,setting age to 0."<<endl;age=0;}}voidPerson::amIOld(){if(age<13)cout<<"You are young."<<endl;elseif(age>=13&&age<18)cout<<"You are a teenager."<<endl;elsecout<<"You are old."<<endl;}voidPerson::yearPasses(){age++;}
Day 4: Class vs. Instance
You are viewing a single comment's thread. Return to all comments →
Why do you need the variable count? I submitted the following code and it passed all 3 test cases (note : to have a better format of your code , start a line with 3 backticks ,then write your code , and at the last line type again 3 backtiks)