Hi guys, I'm new to this but I have no idea what is wrong with my code and I'm going insane trying to figure it out and its due very soon! I would appreciate any help you can give me!

Here's my code:

#include <iostream>
#include <iomanip>

#define ROWS 2
#define COLUMNS 2

class screen 
	{
	static int Row_Position;
	static int Column_Position;

    public:
	const static char Screen_Array [ROWS][COLUMNS]; 

	screen ();
	
	void print();
	};

using namespace std;
int main()
    {
	screen A;
	A.print();
    return 0;
    }
    
screen::screen ()
	{
	Row_Position = 0;
    Column_Position = 0;
	char Screen_Array [ROWS][COLUMNS]={'X','X','X','X'};
	}   

void screen::print()
	{
	int i;
    int j;
	
    for (i=0; i<3; i++)
		{ 
		 for(j=0; i<3; i++)
			 cout << Screen_Array [i][j];
		}
	}

I've tried using quincy now I'm trying Dev-C++ I run the file but nothing prints. Eventually I have to split this into header files and I'm getting a Link error:
undefined reference to "... my class definitions" but when I run this program nothing prints out... I'm so frustrated! Please help me with your wisdom!!! :)

This is a tester array until I make a bigger array but it should print:
XX
XX

One of your issues is that your variables are static. So the scope of the variable is at a class level, not at an object level.

Hence you will probably need to initialize it outside your constructor. In order to access a static variable, at the class level using the scope "::" operator.

example

int screen::Row_Position = 0;
int screen::Column_Position = 0;
char screen::Screen_Array[ROWS][COLUMNS] = {'X','X','X','X'};

now it tells me conflicting declararion of int screen::Column_Position, and the rest of them?

same error as before [Linker error] undefined reference to 'screen::screen()" and same with "screen::print()"... this is when I am separating into a header file which defines my class and a .cc file which has the class definitions

I don't have Dev-C++, but if I do this in Visual C++ if compiles and links correctly. The first is the header file and the next is the cpp file.

#include <iostream>
#include <iomanip>

using namespace std;
 
#define ROWS 2
#define COLUMNS 2
 
class screen 
	{
	static int Row_Position;
	static int Column_Position;
 
  public:
	  static char Screen_Array[ROWS][COLUMNS]; 
 
	screen ();
 
	void print();
	};
#include "test.h"

int screen::Row_Position = 0;
int screen::Column_Position = 0;
char screen::Screen_Array[ROWS][COLUMNS]={'X','X','X','X'};

screen::screen()
{

}   
 
void screen::print()
	{
	int i;
    int j;
 
    for (i=0; i<3; i++)
		{ 
		 for(j=0; i<3; i++)
			 cout << Screen_Array[i][j];
		}
	}

int main()
    {
	screen A;
	A.print();
    return 0;
    }

Yet another wrong code fragment:

#define ROWS 2
#define COLUMNS 2
...
    for (i=0; i<3; i++) { // *** < 2 or better < ROWS
        for(j=0; i<3; i++) // *** j++ !!!; 
            // *** < 2 or better < COLUMNS
            cout << Screen_Array[i][j];
    }
This question has already been answered. Start a new discussion instead.