c++ - How do you call a class and its method when its stored in a pointer array -


how use pointer , call class methods points to?

for example:

image *img[26];  image im = outputimage(); img[0] = &im; 

i want call img[0], or im's methods. tried received errors.

img[0].getpixel(0,1); 

the error "expression must have class type"

since using pointer array, must dereference pointer.

 img[0]->getpixel(0, 1); 

and this:

 image im = outputimage(); 

should be:

 image &im = outputimage(); 

assuming outputimage() returns reference.


Comments