The first statement short* ps = (short*) malloc (100); will allocate 100 bytes of memory.
while the second statement short* ps = (short*) new short (100); will allocate (assuming short is 2 bytes) 200 bytes of memory.
There is no need to typecast the pointer returned by new operator, coz new automatically returns pointer to desired type, unlike malloc which returns void pointer.
The first statement short* ps (short*) malloc (100); will allocate 100 bytes of memory.
while the second statement short* ps (short*) new short (100); will allocate (assuming short is 2 bytes) 200 bytes of memory.
There is no need to typecast the pointer returned by new operator coz new automatically returns pointer to desired type unlike malloc which returns void pointer.