There is a base class in which I need to have a static vector, where I will enter some values ​​in the constructors of the heirs:

class Base { protected: //В этом классе статический вектор static std::vector<double> Vect; //... }; 

In the heir's constructor, I do this:

 Class Deriv : public Base { Deriv() { //.. кроме инициализации членов рассчитываю n и хочу занести в вектор Vect.push_back(n); } }; 

And at this moment Visual Studio (2010) swears:

Unresolved external character "" protected: static class std :: list> Container :: VectVol "(? VectVol @ Container @@ 1V? $ list @ NV? $ allocator @ N @ std @@@ std @@ A)"

How to properly organize a vector in the base class so that all heirs can enter values ​​into it?

1 answer 1

It is necessary not only the announcement, but also the definition of a vector.

Outside the class declaration:

 class Base { protected: //В этом классе статический вектор static std::vector<double> Vect; //... }; 

must be added to some .cpp file:

 std::vector<double> Base::Vect;