This may sound strange, but it seems that I have never thought about overloading of unary operators in C++, which are not implemented as member functions. It's not like it sounds strange or incorrect, I just never wanted to do it. So, just to be able to say "I did it at least once", lets try it out on a very basic example with overloading of postfix increment operator:
#include <cstdlib>
#include <iostream>
class A
{
};
void operator++(const A&, int)
{
std::cout << "Overloaded!" << std::endl;
}
int main(void)
{
A a;
a++;
return EXIT_SUCCESS;
}
The output is easy to guess:
Overloaded!
That's it. I don't have anything more to say about it, because the idea of this post is to fix the fact about this simple thing.
// load comments