#include <iostream>
#include <string>
#include <new>
struct Example_Class
{
char c_style_array[20];
int number;
std::string normal_string;
Example_Class()
: number(7)
, normal_string("Hello, placement new!")
{
}
};
int main()
{
unsigned char my_buffer[sizeof(Example_Class)];
Example_Class *p = new (my_buffer) Example_Class;
std::cout << p->number << std::endl;
std::cout << p->normal_string << std::endl;
p->~Example_Class();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8bmV3PgoKc3RydWN0IEV4YW1wbGVfQ2xhc3MKewogICAgY2hhciBjX3N0eWxlX2FycmF5WzIwXTsKICAgIGludCBudW1iZXI7CiAgICBzdGQ6OnN0cmluZyBub3JtYWxfc3RyaW5nOwogICAgRXhhbXBsZV9DbGFzcygpCiAgICA6IG51bWJlcig3KQogICAgLCBub3JtYWxfc3RyaW5nKCJIZWxsbywgcGxhY2VtZW50IG5ldyEiKQogICAgewogICAgfQp9OwoKaW50IG1haW4oKQp7CiAgICB1bnNpZ25lZCBjaGFyIG15X2J1ZmZlcltzaXplb2YoRXhhbXBsZV9DbGFzcyldOwogICAgRXhhbXBsZV9DbGFzcyAqcCA9IG5ldyAobXlfYnVmZmVyKSBFeGFtcGxlX0NsYXNzOwogICAgc3RkOjpjb3V0IDw8IHAtPm51bWJlciA8PCBzdGQ6OmVuZGw7CiAgICBzdGQ6OmNvdXQgPDwgcC0+bm9ybWFsX3N0cmluZyA8PCBzdGQ6OmVuZGw7CiAgICBwLT5+RXhhbXBsZV9DbGFzcygpOwp9