C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Rescurive to add age Posted by Lindz on 9 Jun 2009 at 1:50 PM
void extEmployeeType::yearsFromRetirement(int age) const
{
     if ((age + 65) == age)
        cout << "It is " << age << " years after retirement";
     else if ((65 - age) == age)
          cout << "It is " << age << " years before retirement";
     else
         extEmployeeType::yearsFromRetirement(age + 1);
}




main.cpp
extEmployeeType age;
    
cout << "Enter age for the person: ";
cin >> age;
cout << endl;
    
person1.print();
cout << endl;
extEmployeeType.yearsFromRetirement();
cout << endl;



Add a recursive function yearsFromRetirement() to the employeeType class as a member function. The function will return the number of years either before or after retirement, supposed to be 65, for a given employeeType instance. For example, if an employeeType instance has the age of 25, the function returns a message “It is 40 years before retirement”. If the employeeType instance has the age of 75, the function returns a message “It is 10 years after retirement (or simply -10 years before retirement)”.

I got the member function the age it's supposed to be I believe, but I'm not quite sure how to get the main function to accept the "age"
53 C:\Users\Owner\Desktop\C++ II\Final\Project2\Project_extemployeePersonType_main.cpp no match for 'operator>>' in 'std::cin >> age'
58 C:\Users\Owner\Desktop\C++ II\Final\Project2\Project_extemployeePersonType_main.cpp expected primary-expression before '.' token

Thread Tree
Lindz Rescurive to add age on 9 Jun 2009 at 1:50 PM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.