class manip{
public:
int t;
manip(int tom){
t = tom;
}
int sub(int val){
return t - val;
}
int add(int val){
return t + val;
}
int perform(int(manip::*key)(int), int val){
return (this->*key)(val);
}
};
int main() {
manip g(5);
cout << g.perform(&manip::add, 9) << ":" << g.perform(&manip::sub, 9);
(This is just a simplified version of a problem im trying to solve in a larger piece of code)
the problem lies here
int(b::*func)(int) = b::add;
int c = func(2);
this gives me a syntax error on the second line (because i have no reference to the "this" data). How do i change it so that the function being called isnt b::add but rather inst.add.
Edit : Posted a working version of the code. Thanks Speed8ump