For example, I have 2 classes A[x,y,z] and B[a,b] and one vector for each class.
I want to read a text file containing data with my two classes
For example the text file may contain:
A [1,2,3]
B [1,2]
A [4,5,6]
How do i read in this file such that the 1st line will be stored as an instance of class A, 2nd line B, 3rd line A again(depending on the file)?
If the file only contains one object(A) i can do a overload operator and
ifstream fileIn( "test.txt" );
while (fileIn >> x >> y>> z) {
//create object A and call push_back on the vector.
}
but I'm having trouble with different objects