Reputation: 2009
I have a class Foo.
class Foo
{
public:
int(_bar)(const int);
Foo(int(bar)(const int))
{
_bar = bar;
}
};
I am trying to pass in a pointer to a static function on creation, and retain that in the class so I can call it later.
I am getting an error of...
error C2659: '=' : function as left operand
...but I don't understand why.
Can anyone please advise?
Upvotes: 0
Views: 356
Reputation: 13288
Function:
int(_bar)(const int);
Function pointer:
int(*_bar)(const int);
You just forgot the *
Upvotes: 2