To warm up with SMFL, I am creating a simple Block Breaker game. For the blocks and balls, I would like to store them as "instances" in a vector so that they can be added/removed with ease.
However, the compiler spits out an error when attempting to access the vector.
block.h
class Block {
private:
bool dead;
public:
Block();
bool isDead();
static std::vector<Block*> blockList;
float x;
float y;
};
main.h
#include "Block.h"
Block playerBlock;
main.cpp
#include "main.h"
int main()
{
playerBlock.x = 50;
playerBlock.y = 20;
Block::blockList.push_back(&playerBlock);
return 0;
}
When compiling, Xcode spits out the following error: Undefined symbols for architecture i386: "Block::blockList", referenced from: _main in main.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any help is welcome. This is not all of my src but it is all of the src related to the problem at hand.