In C++ Im trying to create an object that contains a static list. In the constructor im trying to add the this pointer to the list. Im not really used to using static variables so im probably just making a syntax mistake, but can anyone take a look at this code and take a guess as to why it won't compile.
#ifndef TPRIGIDBODY
#define TPRIGIDBODY
#include <iostream>
#include <vector>
using namespace std;
class tpRigidBody{
private:
public:
static vector<tpRigidBody * const> *rigidBodyList;
tpRigidBody();
~tpRigidBody();
};
#endif // TPRIGIDBODY
#include "tpRigidBody.h"
tpRigidBody::tpRigidBody(){
rigidBodyList->push_back(this);
}
tpRigidBody::~tpRigidBody(){
}
the linker error i get when i try to compile is;
error LNK2001: unresolved external symbol "public: static class std::vector<class tpRigidBody * const,class std::allocator<class tpRigidBody * const> > * tpRigidBody::rigidBodyList" (?rigidBodyList@tpRigidBody@
@2PAV?$vector@QAVtpRigidBody@
@std@@A) tpRigidBody.obj