{
public:
static int const foo = 0;
};
class Bar
{
public:
static int const bar = 0;
};
int main(int argc, char**)
{
return (argc == 1) ? Foo::foo : Bar::bar;
}
Trying to build this with Xcode 3.1.3 on Mac OS X 10.5.7, I get the following linker errors:
Undefined symbols:
"Bar::bar", referenced from:
__ZN3Bar3barE$non_lazy_ptr in main.o
"Foo::foo", referenced from:
__ZN3Foo3fooE$non_lazy_ptr in main.o
ld: symbol(s) not found
Can anyone tell me what is wrong here?
From what I understand, in-class initialization of integral static const variables is allowed in C++.
It also appears that one "can take the address of a static member if (and only if) it has an out-of-class definition."
I don't know the insides of the ternary operator, but I reckon I'm not doing that here.
Thanks.