RAD Studio
ContentsIndex
PreviousUpNext
E2069: Illegal use of member pointer (C++)

Pointers to class members can only be passed as arguments to functions, or used with the following operators:

  • assignment operators
  • comparison operators
  • .*
  • —>*
  • ?: conditional (ternary) operator
  • && logical AND operator
  • || logical OR operator
The compiler has encountered a member pointer being used with a different operator. 

In order to call a member function pointer, one must supply an instance of the class for it to call upon. 

For example:

class A {
public:
   myex();
};
typedef int (A::*Amfptr)();
myex()
{
   Amfptr mmyex = &A::myex;
   return (*mmyex)();  //error
}

This will compile:

class A {
public:
   myex();
};
typedef int (A::*Amfptr)();
foo()
{
   A a;
   Amfptr mmyex = &A::myex;
   return (a.*mmyex)();
}
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!