#include <iostream>
using namespace std;
class DoSomething
{
public:
virtual void unko() = 0;
};
class Humanoid
{
public:
virtual void say() = 0;
};
class Human : public Humanoid, public DoSomething
{
public:
void unko(){
_unko();
}
void say(){ unko(); }
private:
virtual void _unko(){
cout << "Ya-Hoo!!!!!!!!!!!!" << endl;
}
};
class Woman : public Human
{
public:
private:
virtual void _unko(){
cout << "Iyaaaaaaaa!!!!!!!!" << endl;
}
};
class BeautifulGirl : public Humanoid
{
public:
void say(){ cout << "I love you." << endl;}
};
int main()
{
Human a;
Woman b;
BeautifulGirl c;
Humanoid *tmps[] = { &a, &b, &c };
for(int i=0; i<3; i++){ tmps[i]->say(); }
//c.unko(); // !error
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIERvU29tZXRoaW5nCnsKCXB1YmxpYzoKCXZpcnR1YWwgdm9pZCB1bmtvKCkgPSAwOwp9OwoKY2xhc3MgSHVtYW5vaWQKewoJcHVibGljOgoJdmlydHVhbCB2b2lkIHNheSgpID0gMDsKfTsKCmNsYXNzIEh1bWFuIDogcHVibGljIEh1bWFub2lkLCBwdWJsaWMgRG9Tb21ldGhpbmcKewoJcHVibGljOgoJCXZvaWQgdW5rbygpewoJCQlfdW5rbygpOwoJCX0KCQl2b2lkIHNheSgpeyB1bmtvKCk7IH0KCXByaXZhdGU6CgkJdmlydHVhbCB2b2lkIF91bmtvKCl7CgkJCWNvdXQgPDwgIllhLUhvbyEhISEhISEhISEhISIgPDwgZW5kbDsKCQl9Cn07CgpjbGFzcyBXb21hbiA6IHB1YmxpYyBIdW1hbgp7CglwdWJsaWM6Cglwcml2YXRlOgoJCXZpcnR1YWwgdm9pZCBfdW5rbygpewoJCQljb3V0IDw8ICJJeWFhYWFhYWFhISEhISEhISEiIDw8IGVuZGw7CgkJfQp9OwoKY2xhc3MgQmVhdXRpZnVsR2lybCA6IHB1YmxpYyBIdW1hbm9pZAp7CglwdWJsaWM6CgkJdm9pZCBzYXkoKXsgY291dCA8PCAiSSBsb3ZlIHlvdS4iIDw8IGVuZGw7fQoKfTsKCmludCBtYWluKCkKewoJSHVtYW4gYTsKCVdvbWFuIGI7CglCZWF1dGlmdWxHaXJsIGM7CglIdW1hbm9pZCAqdG1wc1tdID0geyAmYSwgJmIsICZjIH07Cglmb3IoaW50IGk9MDsgaTwzOyBpKyspeyB0bXBzW2ldLT5zYXkoKTsgfQoJLy9jLnVua28oKTsgLy8gIWVycm9yCglyZXR1cm4gMDsKfQ==