I have a project due in an hour, and I am stuck on it.

My project is to write some functions for a maze. ( Live regions, Dead Regions, and if it is possible to exit).

The point of the project is to understand graphs and specifically depth first search.

I am having no problems understanding those concepts.

What I need help with is storing/using a 2d boolean object for the visited array.

Here is what I assumed would work, but is not working... (DFS is overloaded)

  bool** visited;
  void DFS() {
        visited = new bool[11][55];
	for (int i = 0; i < XMAX; i++) {
		for (int j = 0; j < YMAX; j++) {
			visited[i][j] = false;
	delete visited;
8 Years
Discussion Span
Last Post by Ancient Dragon

why are you trying to dynamically allocate that array? Just hard-code it bool visited[11][55]; then delete lines 4 and 11.

If it must be dynamically allocated, then you will have to do it like this:

visited = new bool*[11];
      for(int i = 0; i < 11; i++)
          visited[i] = new bool[55];
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.