employee.cpp

来自「Thinking in C, 全世界非常有名的学习C语言的书籍。本源代码含有该书」· C++ 代码 · 共 61 行

CPP
61
字号
// employee.cpp
#include "employee.h"
#include <iostream>
#include <string.h>

Employee::Employee(const char* lst, const char* frst, const char* ttle, int slry)
{
    strcpy(last, lst);
    strcpy(first, frst);
    strcpy(title, ttle);
    salary = slry;
}

const char* Employee::getLast() const
{
    return last;
}

const char* Employee::getFirst() const
{
    return first;
}

const char* Employee::getTitle() const
{
    return title;
}

int Employee::getSalary() const
{
    return salary;
}

void Employee::setLast(const char* lst)
{
    strcpy(last, lst);
}

void Employee::setFirst(const char* frst)
{
    strcpy(first, frst);
}

void Employee::setTitle(const char* ttle)
{
    strcpy(title, ttle);
}

void Employee::setSalary(int slry)
{
    salary = slry;
}

void Employee::print() const
{
    std::cout << '{' << last << ',' << first
              << ',' << title << ',' << salary
              << '}';
}

⌨️ 快捷键说明

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