Hi,
I am still experimenting with STL trying to weigh up the pros and cons. I wish to define nested/embedded classes i.e.
typedef std::vector vector <class B> bVecArray;
typedef std::vector vector<std::string> sVecArray;
class A{
bVecArray bObjArray;
std::srting curLine // current line in dataFile
...
};
class B{
sVecArray header;
};
The class A is used to parse a file containing data which is sliced into different "chunks" using the bObjArray. The data file contains a main header followed by subheaders for each data chunk, and a data-chunk footer
when opening a data file I create an A object
A::A(char *dataFile....)
I can successfully create b objects using bObjArray.push_back(B constructor). However I am having difficulty coding up so that the relevant "chunk" header is written to the current (most recently created) b Object
i.e. I need something like
bObjArray.at(currentBObject).header.push_back(currentLineInFile)
- does not compile
The following does compile
a.temp_header.push_back(curLine);
Clearly something is wrong with above?
Would it be better to use an iterator for the currentBObject?
Or should I first write a temporary header object in A and copy it to the current bObject, and subsequently clear the temporary object? This seems horribly inefficient-
Thanks for taking the time to read this
Mark