c++theory6
페이지 정보
작성일 19-06-17 08:00
본문
Download : c++theory6.hwp
역시 생성자를 定義(정의)하고 접근자와 설정자 멤버 함수도 작성하라. 부모 클래스의 computeSalary()를 재定義(정의) 하라.
소스코드
class SalariedEmployee: public Employee{
int salary; //월급
public://생성자
SalariedEmployee(string n=``,int num=0,int s=0): Employee(n,num),salary(s){};
//접근자 설정자
void setSalary(int s)
{
salary=s;
}…(skip)
c++theory,공학기술,레포트
Download : c++theory6.hwp( 99 )
c++theory6
c++theory6
레포트/공학기술






순서
c++theory6 , c++theory6공학기술레포트 , c++theory
설명
다. 생성자를 定義(정의)하고 접근자와 설정자도 작성하라. 월급을 계산하는 멤버 함수인 computeSalary()를 구현하라.
소스코드
class Employee{
string name; //이름
int num; //사번
public: //생성자
Employee(string n=``,int num=0): name(n),num(num) {};
//설정자 접근자
void setName(string n)
{
name=n;
}
void setNum(int n)
{
num=n;
}
string getName()
{
return name;
}
int getNum()
{
return num;
}
int computeSalary//월급계산 함수
{
cout```월급 계산```endl;
}
};
(2)Employee클래스에서 상속받아서 SalariedEmployee라는 클래스를 定義(정의) 하여 보자 이 클래스는 월급이라는 멤버 변수를 추가로 가진다. c++프로그래밍 theory(이론) 화(6,7)반
학번 : 2xxxxxxxxx 이름 : 고아름
1.회사에서 근무하는 직원들을 나타내는 클래스들을 상속을 이용하여 작성해보자.
(1)Employee클래스를 설계하라. Employee클래스는 이름,사번 등의 정보를 멤버 변수로 가져야 한다.