Reading From File

Hello,
I'm having a bit of trouble while reading from a file.

What I've actually done is created three classes a class one a class Date and a class two. class one is the parent class of class two and class Date is a member of class one.

Now the problem is when I read it from the file first time it displays all the content good and nice but when I carry on it does not take data of Date class, instead show me a garbage value, while all the other data is still good.
Hmmm. And, ... the code?
PlayDB is the class one which has class Date as a data member and the following code is of the member function of class three
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
fstream infile;
	infile.open("CricDB.dat", ios::binary | ios::in);
	SLL *temp1=NULL, *temp2=NULL;
	temp2=new SLL();
	infile.read(reinterpret_cast <char *> (temp2), sizeof(PlayDB));

	FIRST=LAST=temp2;

	while(!infile.eof())
	{
		temp1=temp2;
		temp2=new SLL();
		temp1->next=temp2;
		temp2->next=NULL;
		LAST=temp2;

		infile.read(reinterpret_cast <char *> (temp2), sizeof(PlayDB));
	}
Topic archived. No new replies allowed.