L
linq936
Hi,
I am trying to use C++ functor as callback implementation and I write
the following code to some simple test.
#include <iostream>
using std::cout;
class N0
{
public:
virtual void operator() = 0; // Line 7
};
class Negate : public N0
{
public:
virtual void operator() ( ) { cout << "int:" ;}
};
class Negate2 : public Negate
{
public:
virtual void operator() () { cout << "float:" ;}
};
int main()
{
Negate N1;
Negate2 N2;
N0* table[] = { &N1, &N2};
(*table[0])(); // Line 39
(*table[1])(); // Line 40
}
My compiler is gcc 3.2.3 and it gives me the following error message,
main.c:7: declaration of `operator()' as non-function
main.c: In function `int main()':
main.c:39: no match for call to `(N0) ()'
main.c:40: no match for call to `(N0) ()'
I wonder what is wrong here?
I am trying to use C++ functor as callback implementation and I write
the following code to some simple test.
#include <iostream>
using std::cout;
class N0
{
public:
virtual void operator() = 0; // Line 7
};
class Negate : public N0
{
public:
virtual void operator() ( ) { cout << "int:" ;}
};
class Negate2 : public Negate
{
public:
virtual void operator() () { cout << "float:" ;}
};
int main()
{
Negate N1;
Negate2 N2;
N0* table[] = { &N1, &N2};
(*table[0])(); // Line 39
(*table[1])(); // Line 40
}
My compiler is gcc 3.2.3 and it gives me the following error message,
main.c:7: declaration of `operator()' as non-function
main.c: In function `int main()':
main.c:39: no match for call to `(N0) ()'
main.c:40: no match for call to `(N0) ()'
I wonder what is wrong here?