C++相談室 part62at TECH
C++相談室 part62 - 暇つぶし2ch32:デフォルトの名無しさん
08/05/29 00:58:06
>>29 >>31
ビルトイン型のT()は0初期化の別記法なので、
デフォルトコンストラクタとは呼ばない

テンプレートのために、ユーザー定義型のデフォルトコンストラクタと
同じ記法が使えるようにしてあるだけ

[6.2.8]
The value of an explicit use of the constructor for a builtin
type is 0 converted to that type (§4.9.5).
Thus, int() is another way of writing 0.

For a userdefined type T, T() is defined by the default
constructor (§10.4.2), if any.

The use of the constructor notation for builtin
types is particularly important when writing templates.

Then, the programmer does not know whether a template parameter
will refer to a builtin type or a userdefined
type (§16.3.4, §17.4.1.2).


次ページ
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch