#include <iostream>
using namespace std;
class Chocolate
{
public:
Chocolate() {
cout << "Chocolate ctor" << endl;
}
~Chocolate() {
cout << "Chocolate dtor" << endl;
}
};
class ChocolateCake
{
public:
ChocolateCake() {
cout << "ChocolateCake ctor" << endl;
}
~ChocolateCake() {
cout << "ChocolateCake dtor" << endl;
}
private:
Chocolate chocolate;
};
class Candles
{
public:
Candles() {
cout << "Candles ctor" << endl;
}
~Candles() {
cout << "Candles dtor" << endl;
}
};
class BirthdayCake : public ChocolateCake
{
public:
BirthdayCake() {
cout << "BirthdayCake ctor" << endl;
}
~BirthdayCake() {
cout << "BirthdayCake dtor" << endl;
}
private:
Candles candles;
};
int main(int argc, char *argv[]) {
BirthdayCake birthdayCake;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgogCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKY2xhc3MgQ2hvY29sYXRlCnsKcHVibGljOgogICAgQ2hvY29sYXRlKCkgeyAKICAgIAljb3V0IDw8ICJDaG9jb2xhdGUgY3RvciIgPDwgZW5kbDsgCiAgICB9CiAgICB+Q2hvY29sYXRlKCkgewogICAgICAgIGNvdXQgPDwgIkNob2NvbGF0ZSBkdG9yIiA8PCBlbmRsOwogICAgfQp9OwogCmNsYXNzIENob2NvbGF0ZUNha2UKewpwdWJsaWM6CiAgICBDaG9jb2xhdGVDYWtlKCkgewogICAgICAgIGNvdXQgPDwgIkNob2NvbGF0ZUNha2UgY3RvciIgPDwgZW5kbDsKICAgIH0KICAgIH5DaG9jb2xhdGVDYWtlKCkgewogICAgICAgIGNvdXQgPDwgIkNob2NvbGF0ZUNha2UgZHRvciIgPDwgZW5kbDsKICAgIH0KcHJpdmF0ZToKICAgIENob2NvbGF0ZSBjaG9jb2xhdGU7Cn07CiAKY2xhc3MgQ2FuZGxlcwp7CnB1YmxpYzoKICAgIENhbmRsZXMoKSB7CiAgICAgICAgY291dCA8PCAiQ2FuZGxlcyBjdG9yIiA8PCBlbmRsOwogICAgfQogICAgf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