Placement new on MSVC6

Started by
3 comments, last by Shannon Barber 22 years, 6 months ago
Does MSVC6 handle placement new operations? I couldn''t get it work, but I''ve never done it before, so I don''t know that I''ve got the syntax correct, nor if MSVC6 requires a special flavor if it does it at all.
  
void* pv = malloc(sizeof(int));
int* pi = new(pv) int;
  
Magmai Kai Holmlor - Not For Rent
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
Did you include &ltnew> ?
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
I did this one before =P

int *pi;


pi= new int;

also if you want to put more meat on it ..
pi= new int[yoursizehere];

BTW typecast your void =)


Edited by - GoofProg on October 27, 2001 4:22:35 PM

The nightmare travels across the cosmos with his burning mane. The trail of ash that is produced.

?Have a nice day!?

  unsigned char* pv = (unsigned char*)0x12345678;int* pi = new(pv) int;cout << &*pi << endl;   // Outputs 0x12345678  

Seems to work ... unless I am misunderstanding what placement new does.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Sorry GoofProg, that wasn''t what I was asking about.

Ohhhhhhhhhhhhhhhhh, placement new is a STL overload - I thought it was default behavior Thanks Martee, I didn''t know I needed #include &ltnew>
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement