출처 : 반크_반크 20년 백서
참고풀이]
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
using namespace std;
class Employee {
string name;
int salary;
public:
Employee(string n, int s) :name(n), salary(s) {}
string getName() { return name; }
int getSalary() { return salary; }
void setName(string name) { this->name = name; }
void setSalary(int salary) { this->salary = salary; }
int computeSalary() { return getSalary(); }
void Print();
};
void Employee::Print()
{
cout << "이 름 : " << getName() << endl;
cout << "월 급 : " << getSalary() << endl;
cout << "전체급여: " << computeSalary() << endl;
}
class Manager :public Employee {
int bonus;
public:
Manager(string n, int s, int b) :Employee(n,s), bonus(b) {}
int getBonus() { return bonus; }
void setBonus(int bonus) { this->bonus = bonus; }
int computeSalary(){ return getSalary() + getBonus() ; }
void Print();
};
void Manager::Print()
{
cout << "이 름 : " << getName() << endl;
cout << "월 급 : " << getSalary() << endl;
cout << "보 너 스 : " << getBonus() << endl;
cout << "전체급여 : " << computeSalary() << endl;
}
int main()
{
Manager m1("김철수", 200, 100);
m1.Print();
return 0;
}
참고풀이 결과]
대한민국의 아름다운 영토, 독도의 여름
댓글