. , :
, . , ByteBuffer . , , , .
, , - . , , - , , .
TestClass *global;
void init_globals() {
global = new TestClass("global");
}
int main(int argc, char **argv) {
init_globals();
, global (*global).
TestClass& global() {
static TestClass global_("global");
return global_;
}
global global(). , , init_globals. , - , global(), ... :
unsigned char global_mem[sizeof(TestClass)];
TestClass& global = *(TestClass*)(void*)global_mem;
void init_globals() {
new (global_mem) TestClass("global");
}
int main(int argc, char **argv) {
init_globals();
, - , global global. , init_globals .
Edit:
, , , , .