⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 employee.cpp

📁 《21天学通C++》Teach Yourself C++ in 21 Days (Fourth Edition) 源代码
💻 CPP
字号:
// Employee.cpp
#include <iostream>
#include "Employee.hpp"

int  Employee::GetAge() const
{
   return itsAge;
}
void Employee::SetAge(int age)
{
    itsAge = age;
}
int  Employee::GetYearsOfService() const
{
    return itsYearsOfService;
}
void Employee::SetYearsOfService(int years)
{
    itsYearsOfService = years;
}
int  Employee::GetSalary()const
{
    return itsSalary;
}
void Employee::SetSalary(int salary)
{
    itsSalary = salary;
}


int main()
{
   using namespace std;

    Employee John;
    Employee Sally;

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

    Sally.SetAge(32);
    Sally.SetYearsOfService(8);
    Sally.SetSalary(40000);

    cout << "At AcmeSexist company, John and Sally have ";
    cout << "the same job.\n\n";

    cout << "John is " << John.GetAge() << " years old." << endl;
    cout << "John has been with the firm for " ;
    cout << John.GetYearsOfService() << " years." << endl;
    cout << "John earns $" << John.GetSalary();
    cout << " dollars per year.\n\n";

    cout << "Sally, on the other hand is " << Sally.GetAge(); 
    cout << " years old and has been with the company ";
    cout << Sally.GetYearsOfService();
    cout << " years. Yet Sally only makes $" << Sally.GetSalary();
    cout << " dollars per year! Something here is unfair.";
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -