On Sat, 14 Aug 2004 12:16:12 +0100, "Fraser Ross"
<fraserATmembers.v21.co.unitedkingdom> wrote:
Are these pointers the same?
No. Try this:
#include <iostream>
#include <ostream>
using namespace std;
class A
{
public:
void func() { cout << "Non-const func()." << endl; }
void func() const { cout << "Const func()." << endl; }
};
typedef void (A::* pf)();
typedef void (A::* cpf)() const;
int main()
{
A a;
const A b;
pf fp = &A::func;
cpf cfp = &A::func;
(a.*fp)(); // OK, outputs "Non-const func()."
(a.*cfp)(); // OK, outputs "Const func()."
// (b.*fp)(); // this line won't compile:
// "Cannot convert 'const A *' to 'A *'"
(b.*cfp)();
return 0;
}
--
Bob Hairgrove
No**********@Home.com