Skip to content

Instantly share code, notes, and snippets.

@segfo
Created October 11, 2015 12:25
Show Gist options
  • Save segfo/af7bde1bb1750a308ded to your computer and use it in GitHub Desktop.
Save segfo/af7bde1bb1750a308ded to your computer and use it in GitHub Desktop.
#include<iostream>
#include<string>
#include"TestClass.h"
using namespace std;
int main() {
static char buf[sizeof(TestClass)*10];
cout << sizeof(TestClass) << endl;
TestClass *t1 = new(buf) TestClass("AAAAAAA");
TestClass *t2 = new(buf+sizeof(TestClass)) TestClass("BBBBBBB");
cout << "buf : ";
cout << (void*)buf << endl;
t1->Print();
t2->Print();
getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment