The following code is compiled via gcc but not via VC9. What's going wrong here.
ftor.operator ()(b1); is passing just like ftor.f(b1) but not ftor(b1);
#include "stdafx.h"
#include <iostream>
using namespace std;
class A {};
class B ublic A {};
struct functor
{
template <class T> bool /*f*/operator ()(T* x) { cout << "Generic function is called" << endl; return true; }
};
struct my_functor : public functor {
using functor::/*f*/operator ();
bool /*f*/operator ()(A* x) { cout << "Function for A is called" << endl; return true;}
};
int main()
{
my_functor ftor;
int a=10;
double b=100.0;
B *b1 = new B;
A *a1 = new A;
ftor/*.f*/(&a);
ftor/*.f*/(&b);
ftor/*.f*/(b1);
//ftor.operator ()(b1); // This one is passing but not ftor(b1)
ftor/*.f*/(a1);
}
ftor.operator ()(b1); is passing just like ftor.f(b1) but not ftor(b1);
#include "stdafx.h"
#include <iostream>
using namespace std;
class A {};
class B ublic A {};
struct functor
{
template <class T> bool /*f*/operator ()(T* x) { cout << "Generic function is called" << endl; return true; }
};
struct my_functor : public functor {
using functor::/*f*/operator ();
bool /*f*/operator ()(A* x) { cout << "Function for A is called" << endl; return true;}
};
int main()
{
my_functor ftor;
int a=10;
double b=100.0;
B *b1 = new B;
A *a1 = new A;
ftor/*.f*/(&a);
ftor/*.f*/(&b);
ftor/*.f*/(b1);
//ftor.operator ()(b1); // This one is passing but not ftor(b1)
ftor/*.f*/(a1);
}