So, I'm attempting to write an object oriented program that solves simple sudoku puzzles by checking the rows, columns, and the
3 x 3 grid.

#include <iostream>
using namespace std;
#include "doth.h"
int main()
{
User file:
	Sudoku call;
	int flag=0,ptx=0,pty=0;
	call.Display();	
		for(;flag != 1;)
	{
	         if (Puzzle[ptx][pty]==0)
		{
			void Fill_9();
			void Row(int ptx);
			void Column(int pty);
			void Grid(int ptx,int pty);
		}
		if (ptx<9)
		{
			ptx++;
		}
		if (ptx==9)
		{
			ptx=0;
			pty++;
		}
		if (pty==9)
		{
			ptx=0;
			pty=0;
		}
	}
	call.Display();
return(0);
}

My problem is that when I try to run the program, it tells me that Puzzle is an undeclared identifier, but I declared it publicly within my .h file. What's got me even more confused is when I right click and select "go to declaration" it takes me to the file. What am I doing wrong and how do I fix it?

P.S. Pointing out any other potential Id10t errors would be appreciated.

You say

if (Puzzle[ptx]...

but you haven't defined Puzzle anywhere!

Perhaps I should have stated this earlier. Puzzle is declared in my .h file as

int Puzzle [9][9]

and it gets filled by the constructor function. I tried declaring Puzzle locally and it displays the Puzzle, but it creates problems later resulting in an infinite loop. I'm kinda new to OOP but I thought that if I declare something in the public area I can use it throughout all files in the program.

Is puzzle a member of a class? Or just a global variable that was created in the .h file? Can you post your .h file?

That probably might have helped from the start. Here's the .h file:

class Sudoku
{
private:
	int remains;
	
public:
	Sudoku();
	int flag;
	int Possible[9];
	int Puzzle[9][9];
	void Display();
	void Peek();
	void Fill_9();
	void Update(int ptx, int pty);
	void Row(int ptx);
	void Column(int pty);
	void Grid(int ptx,int pty);
};

Ok so Puzzle is a public member variable of Sudoku. To access it in main, you have to first create an instance of your Sudoku class

Sudoku MySudoku;

Then you can access the Puzzle variable like this

MySudoku.Puzzle[x][y];

You mentioned that Puzzle was filled, but that code must be in your Sudoku.cpp file. Also, why call the file doth.h when it is a Sudoku class?

Well it's running now. It's not functioning properly, but it's working. Thanks for helping me out. And as for for the doth.h, I don't really have a good answer for it. I usually just assign things arbitrary names when I start new projects. Thanks again.

This question has already been answered. Start a new discussion instead.