Could anyone please tell me how do I declare and make use of static vectors & static maps?
I have one base class and 3 classes derived from it. I want the vector populated in one class to be available to the other classes. The only solution I see to it is to make that vector/map static but I dont know how to do it correctly.
//=========== DERIVED CLASS_1 POPULATES THE 'BASE CLASS STATIC VECTOR' ===========
// classDerv1.h
class classDerv1 : public base
{
void populateVect();
};
// classDerv1.cpp
classDerv1::classDerv1 ()
{
}
classDerv1::~classDerv1 ()
{
}
void classDerv1::populateVect()
{
// populate the static vector inherited from base class
}
//=========== DERIVE CLASS-2 'MAKES USE OF THE 'BASE CLASS STATIC VECTOR' POPULATED IN 'DERIVED CLASS_1' ==========='
// classDerv2.h
class classDerv2 : public base
{
void dosomethingtoStaticVect();
};
void classDerv2::dosomethingtoStaticVect()
{
// do something to the static vector inherited from base class and populated in class classDerv1
}