The problem comes because of an interesting clash of new C++ features and what you're trying to do. First, let's take a look at the push_back
signature:
void push_back(const T&)
It's expecting a reference to an object of type T
. Under the old system of initialization, such a member exists. For example, the following code compiles just fine:
#include <vector>
class Foo {
public:
static const int MEMBER;
};
const int Foo::MEMBER = 1;
int main(){
std::vector<int> v;
v.push_back( Foo::MEMBER ); // undefined reference to `Foo::MEMBER'
v.push_back( (int) Foo::MEMBER ); // OK
return 0;
}
This is because there is an actual object somewhere that has that value stored in it. If, however, you switch to the new method of specifying static const members, like you have above, Foo::MEMBER
is no longer an object. It is a constant, somewhat akin to:
#define MEMBER 1
But without the headaches of a preprocessor macro (and with type safety). That means that the vector, which is expecting a reference, can't get one.