i amazed when saw code success compiled ms visual c++.
struct foo { struct foo(int i): value(i) {} int value; }; what means keyword struct in such strange context?
in contexts, can use elaborated type specifier struct foo, or equivalently class foo, instead of class name foo. can useful resolve ambiguities:
struct foo {}; // declares type foo foo; // declares variable same name foo bar; // error: "foo" refers variable struct foo bar; // ok: "foo" explicitly refers class type however, can't use form when declaring constructor, compiler wrong accept code. specification constructor declaration (in c++11 12.1/1) allows class name itself, not elaborated type specifier.
in general, shouldn't surprised when visual c++ compiles kinds of wonky code. it's notorious non-standard extensions language.
Comments
Post a Comment