2

I have successfully overloaded the () operator.

inline real& Array::operator ()(int j,int i) { //TODO checks return array_[i + j*xSize_]; } 

It also works just fine. However i didn't figured out, how to access it within the class itself. For example the following function, which prints all the elements:

for(int y = ySize_ -1; y >= 0; --y) { for( int x = 0; x < xSize_; ++x) { std::cout << this(x,y); } std::cout << std::endl; } 

How do i access it then?

0

1 Answer 1

7

You can use the following syntax:

(*this)(x, y); 

or the longer form:

this->operator()(x, y); 

or

operator()(x,y); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.