I have a class named Foo with static deque of pointers:
Foo.h:
class Foo : public Base
{
public:
static std::deque <Aircraft*> aircrafts;
void updateAircrafts();
...
}
Foo.cpp:
#include "Foo.h"
void Foo::updateAircrafts()
{
for (int i = 0; i < Foo::aircrafts.size(); i++) {
...
}
}
When I'm compiling, I get the following error:
Error LNK2001 unresolved external symbol "private: static class std::deque > Foo::aircrafts" (?aircrafts@Foo@@0V?$deque@PEAVAircraft@@V?$allocator@PEAVAircraft@@@std@@@std@@A) QtGuiApplication1 C:\Users\a_kadirov\source\repos\QtGuiApplication1\Foo.obj 1
and
Error LNK1120 1 unresolved externals QtGuiApplication1 C:\Users\a_kadirov\source\repos\QtGuiApplication1\x64\Debug\QtGuiApplication1.exe 1 Where could be the problem?
I also need to access deque from outside the class, so it must be accessible to other classes. So moving static deque declaration to .cpp file may not work.