So my goal is to make a constructor which makes the object and then puts it in a static list which stores pointers on that objects.
This is my default constructor in cpp file:
Vozac::Vozac()
{
  imevoz=string("");
  brzinavoz=0;
  polozaj=0;
  put=0;
  stanje=0;
  vrsta=0;
  imunost=0;
  vozaci.push_back(this);
}
This is the regular constructor in cpp file:
Vozac::Vozac(string naziv,int x)
{
  imevoz=naziv;
  brzinavoz=x;
  polozaj=0;
  put=0;
  stanje=1;
  vrsta=0;
  imunost=0;
  vozaci.push_back(this);
}
And this is how I defined class Vozac in h file:
class Vozac{
public:
  string imevoz;
  int brzinavoz;
  int polozaj;
  int put;
  int stanje;
  int vrsta;
  int imunost;
  static list<Vozac*> vozaci;
  Vozac();
  Vozac(string naziv,int x);
};
The code compiles alright on its own, but when i try to compile it and link it to one main I get this message:
/tmp/ccT2pGRj.o: In function `Vozac::Vozac()':
vozac.cpp:(.text+0xca): undefined reference to `Vozac::vozaci[abi:cxx11]'
/tmp/ccT2pGRj.o: In function `Vozac::Vozac(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int)':
vozac.cpp:(.text+0x1b1): undefined reference to `Vozac::vozaci[abi:cxx11]'
I am not really sure what does that message mean because as I said the cpp file compiles and the main also compiles on its own. My guess is that I can't use "this" in this situation or did I maybe do something wrong while making the list?
 
    