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)

private:
  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;
		}
	}
	DFS(0,0);
	delete visited;
  }

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];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.