I cannot get pointers to functions to work. I'm still using the teach yourself book, and I have copied various samples letter for letter but I am still getting the same error message...
I just have one class for this example, 1 object and one pointer to access one of the member access methods...
In the class declaration I have...
Code:
int GetAge() {return itsAge;}
Then in main I have...
Code:
int (Cat::*pFunc) ();
int(*pFunc)();
Cat Bob(5);
pFunc = Cat::GetAge;
Bob.*pFunc;
I get this error...
Code:
line 26 error: invalid use of non_static member function 'int Cat::GetAge()'
I have tried every which way I can figure using the examples in the book but I always get this error, what am I doing wrong?
EDIT - Sorry missed some lines in my first post..