Can anyone explain why the following code does not compile (on g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-49))?
struct X { public: enum State { A, B, C }; X(State s) {} }; int main() { X(X::A); }
The message I get is:
jjj.cpp: In function ‘int main()’:
jjj.cpp:10: ‘X X::A’ is not a static member of ‘struct X’
jjj.cpp:10: no matching function for call to ‘X::X()’
jjj.cpp:1: candidates are: X::X(const X&)
jjj.cpp:5: X::X(X::State)`
Is this bad code or a compiler bug?
Problem solved by Neil+Konrad. See the comments to Neil’s answer below.
is being seen a s a function declaration. If you really want this code, use: