This is quite a complicated question. So I have an absolute abstract Base class, and 3 derived classes (A, B, C).
Using the std::ifstream& operator>>(std::ifstream& ifs, Base* a)
I have a file that is set up something like this:
A 5 2
B 2 3
Each line starts with a either A, B, C that tells me the type of class I'm getting, then the actual values for the class.
int a, b;
std::string what;
ifs >> what >> a >> b;
if (what == "A")
{
//create an A class using a, and b.
}
So from the Base operator>> I have to call one of the derived class function where finally 'a' (the Base *) will get either an A, B or C class returned from the funcion, and I'm saving 'a' in a heterogeneous collection.
Is this possible? How do I do this, it feels like I'm just making a circle where I need the Derived class in the Base class and the Base class in the Derived class.