Sorry not sure if this has been asked before, I really dont know what to look up either. I'm new to C++ from Java. When we want to call a function on an object in Java, we say picture.rotateRight();
Then, in rotateRight()
, we'd have something like int height=this.getHeight();
. However, how do we do this in C++? I have a method named invertcolors();
and then I have something like:
Image* myImage = new Image();
bool b = myImage->ReadFromFile("in_01.bmp");
myImage->invertcolors();
void invertcolors(){
int width=TellWidth();
int height=TellHeight();
...
}
How do I access myImage
from the method definition without actually saying myImage
(since that name can later be changed).
Also, the function parameters are non-negotiable.