#include <iostream>
using namespace std;
class Tipo {
int x;
public:
Tipo() {
x = 0;
cout << "construtor padrão\n";
}
Tipo(int p) {
x = p;
cout << "construtor com parâmetro\n";
}
};
class sof {
Tipo teste; //chama o construtor padrão
public:
sof(int t) {
teste = Tipo(t); //chama o outro construtor
}
};
class sof2 {
Tipo teste; //não chama nada
public:
sof2(int t) : teste(t) {} //chama o construtor com parâmetro
};
int main() {
sof exemplo(10);
cout << endl;
sof2 exemplo2(10);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgVGlwbyB7CiAgICBpbnQgeDsKcHVibGljOgogICAgVGlwbygpIHsKICAgICAgICB4ID0gMDsKICAgICAgICBjb3V0IDw8ICJjb25zdHJ1dG9yIHBhZHLDo29cbiI7CiAgICB9CiAgICBUaXBvKGludCBwKSB7CiAgICAgICAgeCA9IHA7CiAgICAgICAgY291dCA8PCAiY29uc3RydXRvciBjb20gcGFyw6JtZXRyb1xuIjsKICAgIH0KfTsKCmNsYXNzIHNvZiB7CiAgICBUaXBvIHRlc3RlOyAvL2NoYW1hIG8gY29uc3RydXRvciBwYWRyw6NvCnB1YmxpYzogCiAgICBzb2YoaW50IHQpIHsKICAgICAgICB0ZXN0ZSA9IFRpcG8odCk7IC8vY2hhbWEgbyBvdXRybyBjb25zdHJ1dG9yCiAgICB9Cn07CgpjbGFzcyBzb2YyIHsKICAgIFRpcG8gdGVzdGU7IC8vbsOjbyBjaGFtYSBuYWRhCnB1YmxpYzogCiAgICBzb2YyKGludCB0KSA6IHRlc3RlKHQpIHt9IC8vY2hhbWEgbyBjb25zdHJ1dG9yIGNvbSBwYXLDom1ldHJvCn07CiAgICAKaW50IG1haW4oKSB7Cglzb2YgZXhlbXBsbygxMCk7Cgljb3V0IDw8IGVuZGw7Cglzb2YyIGV4ZW1wbG8yKDEwKTsKfQ==