A
aaragon
Hi everyone,
Can someone point me out why I can't declare the operator() of a
functor as static? The reason behind this is that I want to be able to
call to the function without instantiating the Functor object. The
code is as follows:
#include <iostream>
using namespace std;
class Functor
{
public:
static void operator()(double c, double f){
cout<<"c -> "<<c<<endl;
cout<<"f -> "<<f<<endl;
}
};
int main()
{
Functor:
perator()(4,5);
return 1;
}
The error message is:
aaragon@aaragon-laptop:~/Desktop$ g++ test.cxx
test.cxx:9: error: 'static void Functor:
perator()(double, double)'
must be a nonstatic member function
Thank you.
Can someone point me out why I can't declare the operator() of a
functor as static? The reason behind this is that I want to be able to
call to the function without instantiating the Functor object. The
code is as follows:
#include <iostream>
using namespace std;
class Functor
{
public:
static void operator()(double c, double f){
cout<<"c -> "<<c<<endl;
cout<<"f -> "<<f<<endl;
}
};
int main()
{
Functor:
return 1;
}
The error message is:
aaragon@aaragon-laptop:~/Desktop$ g++ test.cxx
test.cxx:9: error: 'static void Functor:
must be a nonstatic member function
Thank you.