static const
メンバーがローカル クラスに存在できない理由は何ですか? かなりばかげた制限のようです。
例:
void foo() {
struct bar {
int baz() { return 0; } // allowed
static const int qux = 0; // not allowed?!?
};
}
struct non_local_bar {
int baz() { return 0; } // allowed
static const int qux = 0; // allowed
};
標準 (9.8.4) からの引用:
ローカル クラスには、静的データ メンバーがあってはなりません。