C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

POD's initializations

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Gianluca Silvestri
Guest





PostPosted: Sat Feb 26, 2005 3:41 pm    Post subject: POD's initializations Reply with quote



Hi,
Where in the standard can I find explained the difference between these two
initializations:

struct POD
{
int a;
};

int main()
{
POD* p1 = new POD; //indeterminat value of p1
POD* p2 = new POD(); //default-inizialized
}

Thanks
Gianluca Silvestri


---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Victor Bazarov
Guest





PostPosted: Sun Feb 27, 2005 9:59 pm    Post subject: Re: POD's initializations Reply with quote



"Gianluca Silvestri" <clcppmod-poster (AT) not (DOT) a.valid.address> wrote...
Quote:
Where in the standard can I find explained the difference between these
two initializations:

struct POD
{
int a;
};

int main()
{
POD* p1 = new POD; //indeterminat value of p1
POD* p2 = new POD(); //default-inizialized
}

5.3.4/15


---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Ron Natalie
Guest





PostPosted: Mon Feb 28, 2005 5:06 pm    Post subject: Re: POD's initializations Reply with quote



Gianluca Silvestri wrote:
Quote:
Hi,
Where in the standard can I find explained the difference between thesetwo
initializations:

POD* p1 = new POD; //indeterminat value of p1
POD* p2 = new POD(); //default-inizialized

5.3.4 / 15
A new-expression that creates an object of type T initializes that objectas follows:
— If the new-initializer is omitted:
— If T is a (possibly cv-qualified) non-POD class type (or array thereof), the object is defaultinitialized
(8.5). If T is a const-qualified type, the underlying class type shall have a user-declared
default constructor.
— Otherwise, the object created has indeterminate value. If T is a const-qualified type, or a (possibly
cv-qualified) POD class type (or array thereof) containing (directly or indirectly) a member of
const-qualified type, the program is ill-formed;
— If the new-initializer is of the form (), the item is value-initialized (8.5);

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.