#include <string>
using namespace std;
// 학부생 클래스
class UnderGradStudent
{
public:
string name; // 이름
string department; // 학부
// 학사 경고
void Warn()
{
// 구현 생략
}
};
// 기숙사생 클래스
class DormStudent
{
public:
string building; // 기숙사 명
int roomNumber; // 방번호
// 벌점 부여
void Warn()
{
// 구현 생략
}
};
// 기숙사생이면서 학부생인 경우
class UnderGrad_DormStudent :
public UnderGradStudent,
public DormStudent
{
public:
};
int main()
{
// 기숙사생이면서 학부생인 사람의 정보 생성
UnderGrad_DormStudent std;
std.name = "Hyun C. Lee";
std.department = "Info & Computer Engineering";
std.building = "NamJeKwan";
std.roomNumber = 1529;
// 학사 경고!!
std.Warn();
return 0;
}
둘 다 동일한 warn()함수를 가지고 있으므로 두 개중 하나를 구체화 해줘야 한다.
학사 경고를 줄 경우
std.UnderGradStudent::Warn();
'About 프로그래밍!!! > C++' 카테고리의 다른 글
[C++]bool (0) | 2010.07.08 |
---|---|
[C++]오답노트. (0) | 2010.07.08 |
포함 상속 구분하기 (0) | 2010.07.02 |
다중상속 (0) | 2010.07.02 |
[ARM] 카운터 (0) | 2010.07.02 |