I have the following two classes.
Class A
{
proctected:
A(){}
};
Class B
{
push_new_A_into_v();
vector<A> v;
};
The function
push_new_A_into_v();
will not compile since A's constructor is protected. To make B inherit from A will not help since the method create a completely new A(Why is protected constructor raising an error this this code?).
The reason A's constructor is protected is to make users unable to create an object of type A.
How can I make it possible for the method to work while users is still unable to create objects of type A?