부모 클래스의 virtual 함수를 부르는 법
조회수 10142회
Bar
에서 Foo
의 virtual void printStuff
를 overriding
하면서
Foo
의 printStuff()
를 부르고 싶습니다.
자바에서는 super.printStuff()
같이 쓰면 됐는데
C++에서는 어떻게 쓰나요?
소스코드
class Foo
{
public:
int x;
virtual void printStuff()
{
std::cout << x << std::endl;
}
};
class Bar : public Foo
{
public:
int y;
void printStuff()
{
// Foo.printStuff()을 부르고 싶어요!!!!!!!
std::cout << y << std::endl;
}
};
댓글 입력