#include <cstdlib>
#include <iostream>
class Mamifero
{
public:
Mamifero(){}
~Mamifero(){}
virtual void somMamifero() const
{
std::cout<<"\n\tSom de mamifero.\n";
}
virtual void menu() const
{
Mamifero* mamPtr;
int op;
while(op != 5)
{
std::cout<<"\n\t(1) Boi"
<<"\n\t(2) Gato"
<<"\n\t(3) Porco"
<<"\n\t(4) Cachorro"
<<"\n\t(5) Sair"
<<"\n\tDigite: ";
std::cin>>op;
switch(op)
{
case 1:{
mamPtr = new Mamifero();
mamPtr->somMamifero();
break;
}
case 2:{
mamPtr = new Mamifero();
mamPtr->somMamifero();
break;
}
case 3:{
mamPtr = new Mamifero();
mamPtr->somMamifero();
break;
}
case 4:{
mamPtr = new Mamifero();
mamPtr->somMamifero();
break;
}
case 5:{
std::cout<<"\n\tGood Bye\n\n";
exit(0);
break;
}
default:
std::cout<<"\n\tOpção Inválida ..!!!\n";
}
}
}
};
class Boi: public Mamifero
{
public:
void somMamifero() const
{
std::cout<<"\n\tMuu ..! Muu..!!\n";
}
void menu() const
{
Mamifero* mamPtr;
mamPtr = new Boi();
mamPtr->somMamifero();
}
};
class Gato: public Mamifero
{
public:
void somMamifero() const
{
std::cout<<"\n\tMiAu ..! MiAu..!!\n";
}
void menu() const
{
Mamifero* mamPtr;
mamPtr = new Gato();
mamPtr->somMamifero();
}
};
class Porco: public Mamifero
{
public:
void somMamifero() const
{
std::cout<<"\n\tOinc ..! Oinc..!!\n";
}
void menu() const
{
Mamifero* mamPtr;
mamPtr = new Porco();
mamPtr->somMamifero();
}
};
class Cachorro: public Mamifero
{
public:
void somMamifero() const
{
std::cout<<"\n\tAu ..! Au..!!\n";
}
void menu() const
{
Mamifero* mamPtr;
mamPtr = new Cachorro();
mamPtr->somMamifero();
}
};
int main()
{
Mamifero *m = new Mamifero();;
m->menu();
}
I2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxpb3N0cmVhbT4KIApjbGFzcyBNYW1pZmVybwp7CiBwdWJsaWM6CiAgIE1hbWlmZXJvKCl7fQogICB+TWFtaWZlcm8oKXt9CiAKICAgdmlydHVhbCB2b2lkIHNvbU1hbWlmZXJvKCkgY29uc3QKICAgewogICAgIHN0ZDo6Y291dDw8IlxuXHRTb20gZGUgbWFtaWZlcm8uXG4iOwogIH0KIAogIHZpcnR1YWwgdm9pZCBtZW51KCkgY29uc3QKICB7CiAgIE1hbWlmZXJvKiBtYW1QdHI7CiAgaW50IG9wOwogIHdoaWxlKG9wICE9IDUpCiAgewogICAgc3RkOjpjb3V0PDwiXG5cdCgxKSBCb2kiCiAgICAgICAgICAgICA8PCJcblx0KDIpIEdhdG8iCiAgICAgICAgICAgICA8PCJcblx0KDMpIFBvcmNvIgogICAgICAgICAgICAgPDwiXG5cdCg0KSBDYWNob3JybyIKICAgICAgICAgICAgIDw8IlxuXHQoNSkgU2FpciIKICAgICAgICAgPDwiXG5cdERpZ2l0ZTogIjsKICAgICBzdGQ6OmNpbj4+b3A7CiAgIHN3aXRjaChvcCkKICAgIHsKICAgICBjYXNlIDE6ewogICAgICAgbWFtUHRyID0gbmV3IE1hbWlmZXJvKCk7CiAgICAgICBtYW1QdHItPnNvbU1hbWlmZXJvKCk7CiAgICAgICBicmVhazsKICAgICAgfQogICAgIGNhc2UgMjp7CiAgICAgICBtYW1QdHIgPSBuZXcgTWFtaWZlcm8oKTsKICAgICAgIG1hbVB0ci0+c29tTWFtaWZlcm8oKTsKICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgY2FzZSAzOnsKICAgICAgIG1hbVB0ciA9IG5ldyBNYW1pZmVybygpOwogICAgICAgbWFtUHRyLT5zb21NYW1pZmVybygpOwogICAgICAgYnJlYWs7CiAgICAgIH0KICAgICBjYXNlIDQ6ewogICAgICAgbWFtUHRyID0gbmV3IE1hbWlmZXJvKCk7CiAgICAgICBtYW1QdHItPnNvbU1hbWlmZXJvKCk7CiAgICAgICBicmVhazsKICAgICAgfQogICAgIGNhc2UgNTp7CiAgICAgICBzdGQ6OmNvdXQ8PC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