RAD Studio
ContentsIndex
PreviousUpNext
E2069: Illegal use of member pointer

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

  • assignment
  • comparison

.
->

  • ?:
  • &&
  • ||
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:

cl_ass A {
public:
   myex();
};
typedef int (A::*Amfptr)();
foo()
{
   A a;
   Amfptr mmyex = &A::myex;
   return (a.*mmyex)();
}
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!