K
Kelly Mandrake
Ive been searching this newsgroup for examples and help with pointers
to class methods, there were results but none solved my problem. My
problem is a compiler error.
When I compile the folowing I recieve an error:
Error: must use .* or ->* to call pointer-to-member function in `
pGetAge (...)'
The thing is i have used ->* as directed. Here is what i have
// Main:
int main(int argc, char *argv[])
{
Cat * myCat = new Cat(6);
int (Cat::*pGetAge) (void) const;
pGetAge = &Cat::GetAge;
cout << "Cat is " << myCat->*pGetAge() << " years old!" << endl;
delete myCat;
system("PAUSE");
return EXIT_SUCCESS;
}
=======================
//Class Declaration:
class Cat
{
public:
Cat(int age = 1): mAge(age) {}
~Cat(){}
int GetAge(void) const { return mAge; }
void SetAge(int age) { mAge = age; }
protected:
int mAge;
};
to class methods, there were results but none solved my problem. My
problem is a compiler error.
When I compile the folowing I recieve an error:
Error: must use .* or ->* to call pointer-to-member function in `
pGetAge (...)'
The thing is i have used ->* as directed. Here is what i have
// Main:
int main(int argc, char *argv[])
{
Cat * myCat = new Cat(6);
int (Cat::*pGetAge) (void) const;
pGetAge = &Cat::GetAge;
cout << "Cat is " << myCat->*pGetAge() << " years old!" << endl;
delete myCat;
system("PAUSE");
return EXIT_SUCCESS;
}
=======================
//Class Declaration:
class Cat
{
public:
Cat(int age = 1): mAge(age) {}
~Cat(){}
int GetAge(void) const { return mAge; }
void SetAge(int age) { mAge = age; }
protected:
int mAge;
};
useing gcc 3.3.1From what I read the syntax is corect and this should work. I am