 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Gianluca Silvestri Guest
|
Posted: Sat Feb 26, 2005 3:41 pm Post subject: POD's initializations |
|
|
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
|
Posted: Sun Feb 27, 2005 9:59 pm Post subject: Re: POD's initializations |
|
|
"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
|
Posted: Mon Feb 28, 2005 5:06 pm Post subject: Re: POD's initializations |
|
|
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 |
|
 |
|
|
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
|
|