...OK, let me try another approach. Maybe if I ask this question, some knowledgable soul will enlighten this very willing beginner. Where is this vector loaded? I tried loading it here:
Code:
ifstream& operator >>(ifstream& ifs, BunchOfCards& bcds)
{
for(int i=0;i<bcds.mSomeCards.size();i++)
{
ifs>>bcds.mSomeCards.push_back();
}
return ifs;
}
...but I was told that I was, perhaps, heading down a dark alley.
Let me reflect on another problem I encountered. This one is in many ways similar to the task I am now facing.
When I was first being taught file streams, I was given a problem of inputting from a file. Let me give an example:
I named this file MyFile.dat, and put it into the folder where I was running my program. I discovered after much trial and error, that unless I used something like this:
Code:
ifstream GradesStream;
int aGrade;
string aName;
while(GradesStream>>aGrade>>aName)
...
I would not be able to load the information from the file. I tried for a long time in vain with code such as:
Code:
ifstream GradesStream;
int aGrade;
while(GradesStream>>aGrade)
...
...and as you can imagine, it would not run. Now, I am prepared to use the same strategy here. Again the question comes: Where is the vector loaded? Is it loaded in main()?
Code:
int main()
{
BunchOfCards aDeck;
ifstream aStreamOfCards;
aStreamOfCards.open("Deck.dat");
aStreamOfCards>>aDeck;
while(aStreamOfCards>>aDeck)
{...
return 0;
}
Thanks again in advance.