This is part of my school work but the class is over and now I am just posessed with making it work.
I have a .dat file that looks like this :
1 D d1.bmp
except there are 52 of these groups of three.
I also have a vector of objects where I want to take each group of three data and stick them into 52 objects;
void ClassCardDeckArray ::AddCard(int rank, string suit, string bmpfile)
{
v[NoOfCards] = new CardDeck(rank, suit, bmpfile);
NoOfCards ++;
}
Now, when I open the file I fill only one object instead of filling all 52. Below is snippet where I open the file..
//snippet
fin.open("cards.dat"
if(!fin.is_open())
{
cerr << "error cannot open file" << endl;
exit(1);
}
fin >> rank;
fin >> suit;
fin >> bmp;
ClassCardDeckArray a(52);
a.AddCard(rank, suit, bmp);
Any general suggestions on how to loop thru the file and fill these objects? All the examples I seem to find grab file contents all at once.
I am thinking that maybe I should reference the fin (file input) in the class, something like while(fin.isopen????)...although I can see myself getting lost on that.
Any help at all greatly appreciated!
I have a .dat file that looks like this :
1 D d1.bmp
except there are 52 of these groups of three.
I also have a vector of objects where I want to take each group of three data and stick them into 52 objects;
void ClassCardDeckArray ::AddCard(int rank, string suit, string bmpfile)
{
v[NoOfCards] = new CardDeck(rank, suit, bmpfile);
NoOfCards ++;
}
Now, when I open the file I fill only one object instead of filling all 52. Below is snippet where I open the file..
//snippet
fin.open("cards.dat"
if(!fin.is_open())
{
cerr << "error cannot open file" << endl;
exit(1);
}
fin >> rank;
fin >> suit;
fin >> bmp;
ClassCardDeckArray a(52);
a.AddCard(rank, suit, bmp);
Any general suggestions on how to loop thru the file and fill these objects? All the examples I seem to find grab file contents all at once.
I am thinking that maybe I should reference the fin (file input) in the class, something like while(fin.isopen????)...although I can see myself getting lost on that.
Any help at all greatly appreciated!