H. Sock H. Sock - 1 year ago 73
C++ Question

C++ Casting a pointer in a new?

I have this line of code which I cannot make sense of.

ClassA *pointer= new( ( char* )BASE_ADDRESS)ClassA ;

What does this cast
( ( char* )BASE_ADDRESS)
even mean?

is some memory location.

Answer Source

This is called placement new. It constructs an object of type ClassA and puts it in the memory location specified by BASE_ADDRESS.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download