[表示 : 全て 最新50 1-99 101- 201- 301- 2chのread.cgiへ]
Update time : 05/28 11:19 / Filesize : 97 KB / Number-of Response : 342
[このスレッドの書き込みを削除する]
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧] [類似スレッド一覧]


↑キャッシュ検索、類似スレ動作を修正しました、ご迷惑をお掛けしました

【初心者歓迎】C/C++室 Ver.44【環境依存OK】



228 名前:デフォルトの名無しさん mailto:sage [2007/11/10(土) 12:43:08 ]
>>224
さっきから実装依存だと言ってるのって、名前空間スコープに定義した const 変数の
話じゃないの?

クラスの static const なメンバ変数はクラス定義内では宣言しかされないので、
別途定義が必要。整数型に限って、宣言につけた初期値を持つ定数式として使える
という特別ルールがあるだけ。

C++ 2003 規格の 9.4.2 p2 より
> The declaration of a static data member in its class definition is not a definition and may be of an
> incomplete type other than cv-qualified void. The definition for a static data member shall appear in a
> namespace scope enclosing the member’s class definition.

同じく 9.4.2 p4
> If a static data member is of const integral or const enumeration type, its declaration in the class
> definition can specify a constant-initializer which shall be an integral constant expression (5.19). In that
> case, the member can appear in integral constant expressions. The member shall still be defined in a namespace
> scope if it is used in the program and the namespace scope definition shall not contain an initializer.







[ 続きを読む ] / [ 携帯版 ]

全部読む 前100 次100 最新50 [ このスレをブックマーク! 携帯に送る ] 2chのread.cgiへ
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧](*・∀・)<97KB

read.cgi ver5.27 [feat.BBS2 +1.6] / e.0.2 (02/09/03) / eucaly.net products.
担当:undef