#include <iostream>
using namespace std;
int giid = 0;
class animal {
public:
int id;
int iid;
animal(int _id = 0) {
cout << "construindo um animal..." << endl;
id = _id;
iid = giid++;
}
};
class gato {
public:
int id, iid;
gato(animal a) {
id = a.id;
iid = giid++;
cout << "construtor chamado automaticamente, meaw" << endl;
}
};
int main() {
animal a;
gato xano = a;
cout << "instance id do animal " << a.iid << endl;
cout << "instance id do xano " << xano.iid << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGdpaWQgPSAwOwoKY2xhc3MgYW5pbWFsIHsKcHVibGljOgoJaW50IGlkOwoJaW50IGlpZDsKCWFuaW1hbChpbnQgX2lkID0gMCkgewoJCWNvdXQgPDwgImNvbnN0cnVpbmRvIHVtIGFuaW1hbC4uLiIgPDwgZW5kbDsKCQlpZCA9IF9pZDsKCQlpaWQgPSBnaWlkKys7Cgl9Cgp9OwoKY2xhc3MgZ2F0byB7CnB1YmxpYzoKCWludCBpZCwgaWlkOwoJZ2F0byhhbmltYWwgYSkgewoJCWlkID0gYS5pZDsKCQlpaWQgPSBnaWlkKys7CgkJY291dCA8PCAiY29uc3RydXRvciBjaGFtYWRvIGF1dG9tYXRpY2FtZW50ZSwgbWVhdyIgPDwgZW5kbDsKCX0KfTsKCmludCBtYWluKCkgewogICAgYW5pbWFsIGE7CglnYXRvIHhhbm8gPSBhOwoJCgljb3V0IDw8ICJpbnN0YW5jZSBpZCBkbyBhbmltYWwgIiA8PCBhLmlpZCA8PCBlbmRsOwoJY291dCA8PCAiaW5zdGFuY2UgaWQgZG8geGFubyAiIDw8IHhhbm8uaWlkIDw8IGVuZGw7CglyZXR1cm4gMDsKfQ==