C
CodeMedic
To anyone that is more intelligent than me or just knows better, I
could use some help.
I am attemping to write a simple program that will created a random
maze that will only require for information the cell length and height
of the maze. I am going to use a dynamicly created 2 dimensional array
based on the size parameters given. This is what I have currently:
// Constructor takes the two size parmeters and builds the array.
Maze::Maze (int cRowSize, int cColumnSize)
{
RowSize = cRowSize;
ColumnSize = cColumnSize;
MazeArray = (MazeCell*)calloc((RowSize*ColumnSize),
sizeof(MazeCell));
}
//By the time the constructor is finish each pointer in the array will
have an object or will be null
//not sure ifI need to use delete, free or both
Maze::~Maze (void)
{
int Row = RowSize;
int Column = ColumnSize;
for (;Row > 0 ;Row--)
{
for (;Column > 0;Column--)
delete MazeArray[Row][Column];
}
free(MazeArray);
}
I get this error:
no match for `MazeCell& [int&]' operator
I have had such problems trying to do this is the past. I understand
that I can create a 1D array and then fill each space with another
array but I feel that there could be a better way. Any and all help on
what is seen here would be greatly appreciated.
BTW I am using Xcode on OSX 10.3
CodeMedic
cert# 101010
could use some help.
I am attemping to write a simple program that will created a random
maze that will only require for information the cell length and height
of the maze. I am going to use a dynamicly created 2 dimensional array
based on the size parameters given. This is what I have currently:
// Constructor takes the two size parmeters and builds the array.
Maze::Maze (int cRowSize, int cColumnSize)
{
RowSize = cRowSize;
ColumnSize = cColumnSize;
MazeArray = (MazeCell*)calloc((RowSize*ColumnSize),
sizeof(MazeCell));
}
//By the time the constructor is finish each pointer in the array will
have an object or will be null
//not sure ifI need to use delete, free or both
Maze::~Maze (void)
{
int Row = RowSize;
int Column = ColumnSize;
for (;Row > 0 ;Row--)
{
for (;Column > 0;Column--)
delete MazeArray[Row][Column];
}
free(MazeArray);
}
I get this error:
no match for `MazeCell& [int&]' operator
I have had such problems trying to do this is the past. I understand
that I can create a 1D array and then fill each space with another
array but I feel that there could be a better way. Any and all help on
what is seen here would be greatly appreciated.
BTW I am using Xcode on OSX 10.3
CodeMedic
cert# 101010