#include <iostream>
struct CButton
{
int x, y, z;
CButton() : x(0), y(0), z(0)
{
std::cout << "Default Constructor" << std::endl;
}
CButton(const CButton &from) : x(from.x), y(from.y), z(from.z)
{
std::cout << "Copy Constructor" << std::endl;
}
CButton(int x, int y, int z) : x(x), y(y), z(z)
{
std::cout << "x, y, z Constructor" << std::endl;
}
~CButton()
{
std::cout << "Destructor" << std::endl;
}
};
int main()
{
CButton *pBtn = (CButton*)operator new(sizeof(CButton)*4);
for(unsigned i = 0; i < 4; ++i)
{
new (pBtn+i) CButton(3, 4, 5);
}
delete pBtn;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IENCdXR0b24KewoJaW50IHgsIHksIHo7CglDQnV0dG9uKCkgOiB4KDApLCB5KDApLCB6KDApCgl7CgkJc3RkOjpjb3V0IDw8ICJEZWZhdWx0IENvbnN0cnVjdG9yIiA8PCBzdGQ6OmVuZGw7Cgl9CglDQnV0dG9uKGNvbnN0IENCdXR0b24gJmZyb20pIDogeChmcm9tLngpLCB5KGZyb20ueSksIHooZnJvbS56KQoJewoJCXN0ZDo6Y291dCA8PCAiQ29weSBDb25zdHJ1Y3RvciIgPDwgc3RkOjplbmRsOwoJfQoJQ0J1dHRvbihpbnQgeCwgaW50IHksIGludCB6KSA6IHgoeCksIHkoeSksIHooeikKCXsKCQlzdGQ6OmNvdXQgPDwgIngsIHksIHogQ29uc3RydWN0b3IiIDw8IHN0ZDo6ZW5kbDsKCX0KCX5DQnV0dG9uKCkKCXsKCQlzdGQ6OmNvdXQgPDwgIkRlc3RydWN0b3IiIDw8IHN0ZDo6ZW5kbDsKCX0KfTsKCmludCBtYWluKCkKewoJQ0J1dHRvbiAqcEJ0biA9IChDQnV0dG9uKilvcGVyYXRvciBuZXcoc2l6ZW9mKENCdXR0b24pKjQpOwoJZm9yKHVuc2lnbmVkIGkgPSAwOyBpIDwgNDsgKytpKQoJewoJCW5ldyAocEJ0bitpKSBDQnV0dG9uKDMsIDQsIDUpOwoJfQoJZGVsZXRlIHBCdG47Cn0=
x, y, z Constructor
x, y, z Constructor
x, y, z Constructor
x, y, z Constructor
Destructor