Thank you. I had it all working for a while, then I decided to include a 'resetEnv' member. Something wasn't working and now I'm way off on a tangent. Suppose I have this:
Code:
class lifeBoard
{
public:
typedef int* IntPoint;
private:
struct environment
{
int RCOUNT;
int CCOUNT;
IntPoint *board;
IntPoint *neighborCount;
};
environment* world;
};
Then have a default constructor with, say:
Code:
lifeBoard::lifeBoard(int newRCOUNT,int newCCOUNT)
{
setEnv(newRCOUNT,newCCOUNT);
}
void lifeBoard::setEnv(int newRCOUNT, int newCCOUNT)
{
world=new environment;
world->RCOUNT=newRCOUNT;
world->CCOUNT=newCCOUNT;
world->board=new IntPoint[newRCOUNT];
world->neighborCount=new IntPoint[newRCOUNT];
for(int row=0;row<newRCOUNT;row++)
{
world->board[row]=new int[newCCOUNT];
world->neighborCount[row]=new int[newCCOUNT];
}
setCleanBoard();
}
If I ever want to reference *world.RCOUNT, I use this:
Code:
void lifeBoard::resetEnv(int newRCOUNT, int newCCOUNT)
{
for(int row=0, row<(world->RCOUNT),row++)
{
delete [] world->board[row];
delete [] world->neighborCount[row];
}
delete [] world->board;
delete [] world->neighborCount;
setEnv(newRCOUNT,newCCOUNT);
}
But the compiler spits out this:
Code:
/home/milo/ENG_38/dev [222]> g++ lifeClass-point.cpp
lifeClass-point.cpp: In method `void lifeBoard::resetEnv(int, int)':
lifeClass-point.cpp:59: parse error before `)'
lifeClass-point.cpp:62: void value not ignored as it ought to be
lifeClass-point.cpp:63: parse error before `}'
This is the first function after the class dec, and I'm sure it'd continue on the next one if I moved it.
I know that this is a total overkill for the problem, I am just trying to learn the tools (understand pointers?)
Can you see where I'm going wrong?