GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 202 of 203    Print  
Placement New Syntax
How can a C++ developer use the placement new syntax to make new allocate an object of class SomeClass at a particular memory address stored in a pointer type variable named pmem?

A. new SomeClass(pmem);
B. new(pmem) SomeClass;
C. new SomeClass pmem;
D. new pmem SomeClass;
E. new (pmem, SomeClass);



  
Total Answers and Comments: 3 Last Update: November 15, 2009     Asked by: dlee6565 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: bfeingold
 
B. looks closest to correct.  I would use:

SomeClass* ptr = new(pmem)SomeClass();


Above answer was rated as good by the following members:
yzesong, MercurySystemsEngineering, laetizia
July 29, 2009 17:51:56   #1  
bfeingold Member Since: July 2009   Contribution: 2    

RE: Placement New Syntax
B. looks closest to correct. I would use:

SomeClass* ptr new(pmem)SomeClass();

 
Is this answer useful? Yes | NoAnswer is useful 3   Answer is not useful 0Overall Rating: +3    
October 13, 2009 13:47:20   #2  
krislogy Member Since: October 2009   Contribution: 1    

RE: Placement New Syntax
It is B provided pmem is an allocated pointer (meaning memory already allocated to it).

See this link for more explanation: http://www.geekinterview.com/question_details/16559

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
November 14, 2009 17:02:41   #3  
tawofala Member Since: November 2009   Contribution: 2    

RE: Placement New Syntax
E. new (pmem SomeClass);
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape