C ++ operator overload

I found this code on the web:

Class Book{
Public:
void operator()(int Counter) const throw();
}

My question is: which operator overloads the above code?

+3
source share
2 answers

Firstly, this code is incorrect; since C ++ is case sensitive Classand Publicare not keywords. It is also very unusual (albeit legal) to use the first letter of the parameter name ( Counter).

Assuming proper capitalization, you have an overload of a call function operator. This allows you to “call” the instance Bookas if it were a function:

Book b;
...
b(23);
+11
source

"Functor". "()". STL.

+2

Source: https://habr.com/ru/post/1789439/


All Articles