void *malloc(size_t size);
, , , , - void *, .
foo *pFoo = new foo();
Here, the size is determined by the new one, looking at the layout of the object. Also note that the new statement calls the foo constructor. If you need it, then you did it for malloc, do it as shown below:
void * ptr = new size_t[size];
Not even satisfied ..! You can overload the new statement as you want. Google to overload the new operator.
source
share