Operator That is Pointer to Function

The following sample works in Visual C++ .NET 2003 as specified in the standard:

// operator_that_is_pointer_to_function.cpp
// function style call on object will invoke user-defined conversion 
// if there is one. See secion 13.3.1.1.2 
typedef void(*ptf)();
void func()
{
}
struct S
{
   operator ptf()
   {
      return func;
   }
};

int main()
{
   S s;
   s();//operates as s.operator ptf()()
}

See Also

Other Resources

Visual C++ .NET 2003 Enhanced Compiler Conformance