#include <vector>
#include <queue>
class A
{
std::vector<float> vA;
virtualvoid process();
public:
A() { vA.push_back(0); }
};
class B : public A
{
std::queue<int> qB;
virtualvoid process();
public:
B() {qB.push(0);}
};
class ContainerA
{
A const& mA;
public:
ContainerA(A const& a) : mA(a) {}
};
class ContainerB : public ContainerA
{
B const& mB;
public:
ContainerB(B const& b) : mB(b) {}
};
int main()
{
B b;
ContainerB cb(b);
}
> but there is no constructor Container A(B const&)
The one that's called is Container A(A const&)
> both A and ContainerA are legacy code and supposed to remain unchanged
I am not complaining about ContainerA, but ContainerB
Inheritance is a bad choice as you want to strength a precondition (instead of A objects you ask for B objects) http://www.parashift.com/c++-faq/parkinglot-of-car-vs-vehicle.html