Post date: May 02, 2017 1:22:23 PM
Say you have any data structure and you access it by a pointer i.e.
SomeStruct* ss = new SomeStruct();
the new keyword allocates memory for the struct and in so doing, assigns an address.that the pointer uses. Now say that you assign this pointer to another function or thread e.g.
SomeStruct* sos = ss;
If then at some point, you do a new from sos i.e.
sos = new SomeStruct();
this again allocates memory for the struct and here is the clincher, it assigns a different address to sos but NOT ss. Sometimes, I want to keep the same address so the way to do that is
sos = new (ss) SomeStruct();
This tidy little addition keeps the ss and sos pointing to the same thing.