#include <iostream>
struct A
{
int size;
int* array = new int[size](); // array of 0-initialized ints
A(int array_size = 10) : size(array_size) {}
~A() { delete [] array; }
};
void show_data(const A& a)
{
std::cout << "For object of type 'A' at address " << &a ;
std::cout << "\n\tsize = " << a.size;
std::cout << "\n\tarray = " << a.array;
std::cout << "\n\tarray contents:\n";
for (unsigned i = 0; i < a.size; ++i)
std::cout << "\t\t" << i << ": " << a.array[i] << '\n';
std::cout << '\n';
}
int main()
{
A a;
show_data(a);
A b(5);
show_data(b);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IEEKewogICAgaW50IHNpemU7CiAgICBpbnQqIGFycmF5ID0gbmV3IGludFtzaXplXSgpOyAgIC8vIGFycmF5IG9mIDAtaW5pdGlhbGl6ZWQgaW50cwoKICAgIEEoaW50IGFycmF5X3NpemUgPSAxMCkgOiBzaXplKGFycmF5X3NpemUpIHt9CgogICAgfkEoKSB7IGRlbGV0ZSBbXSBhcnJheTsgfQp9OwoKdm9pZCBzaG93X2RhdGEoY29uc3QgQSYgYSkKewogICAgc3RkOjpjb3V0IDw8ICJGb3Igb2JqZWN0IG9mIHR5cGUgJ0EnIGF0IGFkZHJlc3MgIiA8PCAmYSA7CiAgICBzdGQ6OmNvdXQgPDwgIlxuXHRzaXplID0gIiA8PCBhLnNpemU7CiAgICBzdGQ6OmNvdXQgPDwgIlxuXHRhcnJheSA9ICIgPDwgYS5hcnJheTsKICAgIHN0ZDo6Y291dCA8PCAiXG5cdGFycmF5IGNvbnRlbnRzOlxuIjsKCiAgICBmb3IgKHVuc2lnbmVkIGkgPSAwOyBpIDwgYS5zaXplOyArK2kpCiAgICAgICAgc3RkOjpjb3V0IDw8ICJcdFx0IiA8PCBpIDw8ICI6ICIgPDwgYS5hcnJheVtpXSA8PCAnXG4nOwoKICAgIHN0ZDo6Y291dCA8PCAnXG4nOwp9CgppbnQgbWFpbigpCnsKICAgIEEgYTsKICAgIHNob3dfZGF0YShhKTsKCiAgICBBIGIoNSk7CiAgICBzaG93X2RhdGEoYik7Cn0=