Thread: Easy Program.....won't compile Help!!!!!!!!!!!!

  1. #1
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427

    Talking Easy Program.....won't compile Help!!!!!!!!!!!!

    #include <iostream>
    class employee
    {
    public:


    int GetAge() const;
    void SetAge( int age);
    int SetYearsOfService( int years);
    int SetSalary (int salary);
    int GetYearsOfService()const;
    int GetSalary()const;
    private:
    int Age;
    int YearsOfService;
    int Salary;
    };

    void employee::SetAge(int age)
    {
    return Age=age;
    }

    int employee::GetAge()
    {
    return Age;
    )

    void employee::SetYearsOfService(int years)
    {
    return YearsOfService=years;
    }

    int employee::GetYearsOfService()
    {
    return YearsOfService;
    }

    void employee::SetSalary (int salary)
    {
    return Salary=salary;
    }

    int employee::GetSalary()
    {
    return Salary;
    }
    using namespace std;
    int main()

    {

    employee John;
    employee Sally;
    John.SetAge (30);
    John.SetYearsOfService(5);
    John.SetSalary(50000);

    Sally.SetAge(32);
    Sally.SetYearOfService(5);
    Sally.SetSalary(40000);
    cout<<"At AcmeSexist company, John and Sally have the same job \n";
    cout<<"John is "<<John.GetAge()<<" years old and he has with";
    cout<<"the firm for "<<John.GetYearOfService()<<"years \n";
    cout<<"John earns $"<<John.GetSalary()<<"dollars per year.\n";
    cout<<"Sally on the other hand is "<<Sally.GetAge()<<"years old and has";
    cout<<"been with the company "<<Sally.GetYearOfService();
    cout<<"years. Yet Sally only makes $" <<Sally.GetSalary();
    cout<<"dollars per year! Something here is unfair. ";


    int x;
    cin>>x;
    return 0;
    }
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    3
    you have functions of type void, returning a value, that's the first problem that i can see.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    3
    here you go, i've tweeked your code and this works:

    #include <iostream>
    class employee
    {
    public:


    int GetAge();
    int SetAge( int age);
    int SetYearsOfService( int years);
    int SetSalary (int salary);
    int GetYearsOfService();
    int GetSalary();

    private:
    int Age;
    int YearsOfService;
    int Salary;

    };

    int employee::SetAge(int age)
    {
    return Age=age;
    }

    int employee::GetAge()
    {
    return Age;
    }

    int employee::SetYearsOfService(int years)
    {
    return YearsOfService=years;
    }

    int employee::GetYearsOfService()
    {
    return YearsOfService;
    }

    int employee::SetSalary (int salary)
    {
    return Salary=salary;
    }

    int employee::GetSalary()
    {
    return Salary;
    }


    using namespace std;
    int main() {

    employee John;
    employee Sally;
    John.SetAge (30);
    John.SetYearsOfService(5);
    John.SetSalary(50000);

    Sally.SetAge(32);
    Sally.SetYearsOfService(5);
    Sally.SetSalary(40000);
    cout<<"At AcmeSexist company, John and Sally have the same job \n";
    cout<<"John is "<<John.GetAge()<<" years old and he has with";
    cout<<"the firm for "<<John.GetYearsOfService()<<"years \n";
    cout<<"John earns $"<<John.GetSalary()<<"dollars per year.\n";
    cout<<"Sally on the other hand is "<<Sally.GetAge()<<"years old and has";
    cout<<"been with the company "<<Sally.GetYearsOfService();
    cout<<"years. Yet Sally only makes $" <<Sally.GetSalary();
    cout<<"dollars per year! Something here is unfair. ";


    int x;
    cin>>x;
    return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help newbie compile program!
    By candysandra88 in forum C Programming
    Replies: 7
    Last Post: 12-13-2008, 11:27 PM
  2. Cannot compile a C program in Visual C++ Express
    By daYz in forum C Programming
    Replies: 10
    Last Post: 03-09-2008, 10:47 AM
  3. program compile help
    By farminbob in forum C Programming
    Replies: 5
    Last Post: 12-04-2007, 12:03 PM
  4. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  5. Using a makefile to compile a program using SDL
    By Noerbo in forum Game Programming
    Replies: 9
    Last Post: 04-30-2006, 09:11 AM