The usage of class name with the overloaded parentheses [duplicate]

  c++, class, operator-overloading

In the following example, I understand what boost signal does, however, my question is about how the class name with the overloaded parentheses HelloWorld() is used. What is this practice called and what is its common application?

#include <boost/signals2.hpp>
#include <iostream>
struct HelloWorld 
{
  void operator()(int val_) const 
  { 
    std::cout << "Hello, World!" << val_  << std::endl;
  } 
};
int main()
{
boost::signals2::signal<void (int)> sig;
HelloWorld hello;
hello(6);
sig.connect(HelloWorld());
sig(5);
}

Source: Windows Questions C++

LEAVE A COMMENT