Hi there
I have a class within which i assign 2 dimension dynamic array of pointers which points to variable inside these class (variable is of type other class).
Now to get into that variable I have to use ptr-> but my ptrtoobj[i][j] is pointer to pointer and left hand side of -> has to be pointer to class/structure
when I use ptrtoobj[i][j]->class_variab le I'm getting an error of
type 'cell' does not have an overloaded member 'operator ->' see declaration of 'cell'
Any idea for overloaded function operator-> or to solve these
I know that 1 dimension array would be solution but 2 is easier for calculations for me
Here is code
//constructor and destructor works fine I have tested that
class Game
{
public:
void display();
Game();
Game(int);
virtual ~Game();
private:
int size;
cell **ptrtoobj;
};
Game::Game(int s)
{
size=s;
ptrtoobj=new cell*[size];
for (int i=0; i<size; i++)
{
ptrtoobj[i]= new cell[size];
}
}
Game::~Game()
{
for (int i =0; i<size; i++)
{
delete[] ptrtoobj[i];
}
delete[] ptrtoobj;
}
I sorry for language but English isn't my native language :-)
Regards QryS
I have a class within which i assign 2 dimension dynamic array of pointers which points to variable inside these class (variable is of type other class).
Now to get into that variable I have to use ptr-> but my ptrtoobj[i][j] is pointer to pointer and left hand side of -> has to be pointer to class/structure
when I use ptrtoobj[i][j]->class_variab le I'm getting an error of
type 'cell' does not have an overloaded member 'operator ->' see declaration of 'cell'
Any idea for overloaded function operator-> or to solve these
I know that 1 dimension array would be solution but 2 is easier for calculations for me
Here is code
//constructor and destructor works fine I have tested that
class Game
{
public:
void display();
Game();
Game(int);
virtual ~Game();
private:
int size;
cell **ptrtoobj;
};
Game::Game(int s)
{
size=s;
ptrtoobj=new cell*[size];
for (int i=0; i<size; i++)
{
ptrtoobj[i]= new cell[size];
}
}
Game::~Game()
{
for (int i =0; i<size; i++)
{
delete[] ptrtoobj[i];
}
delete[] ptrtoobj;
}
I sorry for language but English isn't my native language :-)
Regards QryS
Comment