Reputation: 65
I found this code on internet :
Class Book{
Public:
void operator()(int Counter) const throw();
}
My question is, what operator overloading the above code used?
Upvotes: 3
Views: 246
Reputation: 6901
The above class is basically called a "Functor". It has an overloaded "()" operator. Widely used in STL Algorithms.
Upvotes: 2
Reputation: 186098
Firstly, that code is wrong; since C++ is case sensitive, Class
and Public
are not keywords. It is also very unusual (albeit legal) to capitalize the first letter of a parameter name (Counter
).
Assuming correct capitalization, what you have is an overload of the function-call operator. It allows you to "call" an instance of Book
as if it was a function:
Book b;
...
b(23);
Upvotes: 11