Request for member ".." which is of non-class type

Hi everyone.. I get this error:

"request for member ‘on’ in ‘((Display*)this)->Display::display’, which is of non-class type ‘int [8][8]"

My classes are there:

class Display
{
private:
bool display[8][8];

public:
// Costruttore
Display();

// Distruttore
~Display();

// Metodi
void on(int x, int y);
void off(int x, int y);

void A();
};

And this:

#include "Display.hh"

Display::Display()
{
display[8][8];
for (int i=0; i<8; i++)
{
for (int j=0; j<8; j++)
{
display[i][j].off(i, j);
}
}
}

Display::~Display()
{;}

void Display::on(int x, int y)
{
display[x][y]=true;
}

void Display::off(int x, int y)
{
display[x][y]=false;
}

void Display::A()
{
int i,j;
while (i==2 || i==5)
{
for (j=2; j<6; j++)
{
display.on(i, j);
}
}
while (i==3 || i==4)
{
while (j==1 || j==4)
{
display.on(i, j);
}
}
}

Does anyone know where is the problem??
Last edited on
display[8][8];
What are you trying to do on this line? Remember that indexing starts at zero so this is actually an out of bounds access.

display[i][j].off(i, j);
display[i][j] is a bool and have no member functions. Only classes can have member functions

display.on(i, j);
display is an array so it have no member functions.
Your class is called Display, the data member that you declared inside is called display. C++ is type sensitive, so you're trying to call the function "on" for "display" which is an array of 64 bools. Obviously this won't work.
If you want to call a member function inside a class just use the function's name.
Topic archived. No new replies allowed.