Let's say I have the following definitions:
class ScriptInterpreter {
public:
class cell;
typedef ScriptInterpreter::cell (ScriptInterpreter::*proc_t) (const std::vector<cell> &);
class cell {
public:
proc_t proc;
};
ScriptInterpreter::cell proc_add(const std::vector<cell> & c);
};
And the following code going on:
ScriptInterpreter::eval(ScriptInterpreter::cell cell, environment * env)
{
// ...
ScriptInterpreter::cell c;
c.proc = &ScriptInterpreter::proc_add;
return (c.*proc_)(exps);
}
At the line where I try to call the function pointer I get the error
error: called object type 'proc_t' (aka 'ScriptInterpreter::cell (ScriptInterpreter::*)(const std::vector<cell> &)') is not
a function or function pointer
When I add the * in front of the func so the line looks like this:
ScriptInterpreter::cell c = (proc_cell.*proc_)(exps);
it produces this:
error: use of undeclared identifier 'proc_'
I already looked at Callback functions in c++ and other problems of that kind, but nothing really gave me a hint what's wrong or provided any information about my error. I definitely don't have any names twice or something of that kind. Also after reading what is an undeclared identifier error and how do i fix it I'm pretty sure I got everything alright.
So what am I doing wrong?
Edit: updated the code with real code instead of placeholder code