mercredi 1 avril 2015

2d pointer as a data member of class

i have to write a code for matrix addition using a oop. I made a 2d pointer as a data member of my class. I initialized my pointer in the default and parameterized constructor. When i am trying to access the elements to which my 2d pointer is pointing i get error.



void Add(int const &a)
{
for(int x=0;x<row;x++)
{
for(int y=0;y<col;y++)
{
(*(*p+row)+col)=(*(*p+row)+col)+(a.(*(*p+row)+col));
}
}
}


int **p is my 2d pointer data member here. I am new to classes any help would be appreciated.


Aucun commentaire:

Enregistrer un commentaire