#include <iostream>
#include <vector>
using namespace std;
class MyObj
{
public:
int a;
int b;
MyObj( int ai, int bi )
{
cout << "constructor of "<<this << endl;
this->a = ai;
this->b = bi;
}
MyObj(const MyObj& other) // copy constructor
{
cout<<"copy constructor of " <<this<<endl;
}
~MyObj()
{
cout<<"destructor of "<<this<<endl;
}
};
vector<MyObj> myVec;
void foo()
{
MyObj objInst( 10, 20 );
myVec.push_back( objInst );
}
int main() {
cout << "main start" <<endl;
foo();
cout << "main end"<<endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjbGFzcyBNeU9iagp7CglwdWJsaWM6CglpbnQgYTsKCWludCBiOwoKCU15T2JqKCBpbnQgYWksIGludCBiaSApCgl7CiAgIAkJY291dCA8PCAiY29uc3RydWN0b3Igb2YgIjw8dGhpcyA8PCBlbmRsOwogICAgCXRoaXMtPmEgPSBhaTsKICAgIAl0aGlzLT5iID0gYmk7Cgl9CgoJTXlPYmooY29uc3QgTXlPYmomIG90aGVyKSAgLy8gY29weSBjb25zdHJ1Y3RvcgoJewoJCWNvdXQ8PCJjb3B5IGNvbnN0cnVjdG9yIG9mICIgPDx0aGlzPDxlbmRsOwoJfQoJCgl+TXlPYmooKQoJewoJCWNvdXQ8PCJkZXN0cnVjdG9yIG9mICI8PHRoaXM8PGVuZGw7Cgl9CgogIAp9OwoKdmVjdG9yPE15T2JqPiBteVZlYzsKCnZvaWQgZm9vKCkKewogICAgTXlPYmogb2JqSW5zdCggMTAsIDIwICk7CiAgICBteVZlYy5wdXNoX2JhY2soIG9iakluc3QgKTsKfQoKaW50IG1haW4oKSB7Cgljb3V0IDw8ICJtYWluIHN0YXJ0IiA8PGVuZGw7Cglmb28oKTsKCWNvdXQgPDwgIm1haW4gZW5kIjw8ZW5kbDsKCglyZXR1cm4gMDsKfQ==