Re[2]: про new и new()
От: Lorenzo_LAMAS  
Дата: 16.02.05 10:43
Оценка:
L_L>Разница между new T и new T() для не POD типов по текущему (т.е. не 1998 года) стандарту есть, потому во втором случае у тебя нули — имеет место value-initialization.

Вот что у меня в ревижне к стандарту :

5.3.4/15

A new-expression that creates an object of type T initializes that object as follows:
...
— if the new-initializer is of the form (), the item is value-initialized (8.5)
...
8.5

To value-initialize an object of type T means:
...
— if T is a non-union class without a user-declared constructor, then every non-static data member and base
class component of T is value-initialized
...
— otherwise, the object is zero-initialized (я опустил многие пункты, но этот otherwise — это как раз члены-
данные, которые у тебя 0)

Of course, the code must be complete enough to compile and link.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.