hellooo.....
i wrote this code.. which is a part of a bigger code...
i have done this using structs..
now i have to do it with class but i dont know much about classes
need help urgently..... :(
#include<iostream>
#include<fstream>
using namespace std;
class cell
{
bool visited;
cell *back;
cell *d[4];
};
int readIn( cell** path)
{
cell *cells;
int a;
int b;
int c;
int d;
ifstream fin;
fin.open("file.txt");
int size;
fin>>size;
cells= new cell[size];
for(int i=0; i<size; i++)
{
cells[i].visited=false;
cells[i].back= NULL;
fin>>a>>b>>c>>d;
if(a==-1)
cells[i].d[0]=NULL;
else
cells[i].d[0]=&cells[a];
if(b==-1)
cells[i].d[1]=NULL;
else
cells[i].d[1]=&cells[b];
if(c==-1)
cells[i].d[2]=NULL;
else
cells[i].d[2]=&cells[c];
if(d==-1)
cells[i].d[0]=NULL;
else
cells[i].d[3]=&cells[d];
}
*path= cells;
return size;
}