#include <iostream>
class Base{
protected :
virtual void Hoge( ) = 0 ;
void Huga( ) {
std:: cout << "I cry in Base::Huga();" << std:: endl ;
}
virtual void Hage( ) {
std:: cout << "My head is not Light!!" << std:: endl ;
}
public :
void CallA( ) {
std:: cout << "*Base::CallA is start*" << std:: endl ;
Hoge( ) ;
Huga( ) ;
Hage( ) ;
std:: cout << "*Base::CallA is end!*" << std:: endl ;
}
} ;
class Derived: public Base{
protected :
virtual void Hoge( ) {
std:: cout << "Override Hoge in Derived!" << std:: endl ;
}
void Huga( ) {
std:: cout << "I cry in Derived::Huga();" << std:: endl ;
}
virtual void Hage( ) {
std:: cout << "I need Heir!!" << std:: endl ;
}
public :
void CallB( ) {
std:: cout << "*Derived::CallB is start*" << std:: endl ;
CallA( ) ;
Hoge( ) ;
Huga( ) ;
Hage( ) ;
std:: cout << "-Call the base method from derived!^" << std:: endl ;
//Base::Hoge();
Base:: Huga ( ) ;
Base:: Hage ( ) ;
std:: cout << "*Derived::CallB is end!*" << std:: endl ;
}
} ;
int main( ) {
Derived D;
Base* B = & D;
std:: cout << "-------------------------" << std:: endl ;
B- > CallA( ) ;
std:: cout << "-------------------------" << std:: endl ;
D.CallB ( ) ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgpjbGFzcyBCYXNlewpwcm90ZWN0ZWQ6Cgl2aXJ0dWFsIHZvaWQgSG9nZSgpPTA7CgoJdm9pZCBIdWdhKCl7CgkJc3RkOjpjb3V0PDwiSSBjcnkgaW4gQmFzZTo6SHVnYSgpOyI8PHN0ZDo6ZW5kbDsKCX0KCgl2aXJ0dWFsIHZvaWQgSGFnZSgpewoJCXN0ZDo6Y291dDw8Ik15IGhlYWQgaXMgbm90IExpZ2h0ISEiPDxzdGQ6OmVuZGw7Cgl9CgpwdWJsaWM6Cgl2b2lkIENhbGxBKCl7CgkJc3RkOjpjb3V0PDwiKkJhc2U6OkNhbGxBIGlzIHN0YXJ0KiI8PHN0ZDo6ZW5kbDsKCQlIb2dlK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