Why aren't static data members allowed in local classes?
问题 What is the reasoning to why static const members cannot exist in local classes? It seems like a rather silly restriction. Example: 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 }; Quote from standard (9.8.4): A local class shall not have static data members. 回答1: From the standard section 9.4.2: If a static data member is of const