Its because you don't have an instance of playfield in your function. There are two ways around this depending on how exactly you want to implement your code. One is to make clearfield a member function of the class (preferred method):
Code:
class playfield
{
public:
playfield();
~playfield();
void clrfield();
int field[10][10][2];
int expnumber;
};
playfield::playfield()
{
}
playfield::~playfield()
{
}
void playfield::clrfield()
{
int a, b;
for (a=0;a<=10;a++){
for (b=0;b<=10;b++){
field[a][b][1]=0;
}
}
}
Or if you intend for the function to not be a part of the class then you have to declare an instance of playfield in your function like you would any other variable type like int, char, etc (not-preferred):
Code:
class playfield
{
public:
playfield();
~playfield();
int field[10][10][2];
int expnumber;
};
playfield::playfield()
{
}
playfield::~playfield()
{
}
void clrfield()
{
int a, b;
playfield myPlayfield;
for (a=0;a<=10;a++){
for (b=0;b<=10;b++){
myPlayfield.field[a][b][1]=0;
}
}
}
This last variation is not preferable since its usually a bad idea to allow the user direct access to the data of a class.