Is it possible to store multiple objects of one class into a dynamic array found in another class?
This is my main():
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
ifstream inStream;
ofstream outStream;
string filename1, aSequence;
Circle<string> theSequences(30); //loaded constructor creates dynamic array of size 30
....
while (!inStream.eof()) {
Weighable* theSequence = new DNA(); //DNA extends Weighable (Weighable is completely virtual)
getline(inStream, aSequence); //get line from .txt file, store in string type aSequence
theSequence -> setSequence(aSequence); //creates a sequence to be stored into Circle's dynamic array
theSequences.set(theSequence); //store the object into the dynamic array found in Circle ???
theSequences.moveNext(); //moves the point of reference (changes dynamic array's index to be filled i.e. first line = dynamicArray[0], second line = dynamicArray[1], etc. )
delete theSequence;
theSequence = NULL;
}
inStream.close(); //close the inStream
Am I on the right track? I want objects of DNA to be stored in Circle's dynamic array. The sequence must be an object of DNA.