Although, the OP said it should only work with foo, which in that case, why are we bothering with pointers to functions?Code:
Code:
static int X::bar(X object) { object.foo();}
Well, this is true. That is a whole lot simpler and ensures that only foo will be called of instances of X.
Oh...Can't imagine I couldn't think of that...!!
It'd solve my current problem in a very elegant way...
I had two objects...and a static function for connecting them..
Code:
connect(X a,X b) {b.func2(a.func1());}
//would be the skeletal structure of it..apart from exception handling/..