블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2731)
Unity3D (814)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (57)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (51)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
03-29 00:00

class에서 다중 상속을 받게 될 경우 그 부모의 함수를 호출하는데 부모 클래스의 이름이 필요하다.

이때 해당 클래스의 이름을 적지 않아도 __super 라는 키워드를 이용해 부모클래스를 찾아 해당

함수를 호출하도록 할 수 있다. 아래는 MSDN에 수록된 __super 의 사용 예다.

// deriv_super.cpp
// compile with: /c
struct B1 {
  void mf(int) {}
};

struct B2 {
  void mf(short) {}

  void mf(char) {}
};

struct D : B1, B2 {
  void mf(short) {
     __super::mf(1);   // Calls B1::mf(int)
     __super::mf('s');   // Calls B2::mf(char)
  }
};



반응형

'Programming > C/C++' 카테고리의 다른 글

TCHAR printf  (0) 2010.07.12
A * pA = new B 과 B * pB = new B의 차이점.  (0) 2010.06.21
[펌] assert 문 사용하기  (0) 2010.05.13
[펌] try-catch 예외처리 비용?  (0) 2010.05.13
[펌] 순수 가상 소멸자  (2) 2010.05.06
Posted by blueasa
, |