RSS
Follow Us
Contribute
 
 
 
 

Error C2276: (operator) : illegal operation on bound member function expression

 
We need YOUR SKILLS in this collaborative work, to build the largest solution center for error messages.

From $1

Table of contents
  1. 1. Cause
  2. 2. Solution
  3. 3. About This Article

Cause

The compiler found a problem with the syntax to create a pointer-to-member. Ex:

class A {
public:
   int func(){return 0;}
} a;

int (*pf)() = &a.func;   // C2276

class B {
public:
   void mf() {
      &this -> mf;   // C2276
   }
};

int main() {
   A a;
   &a.func;   // C2276
}

Solution

Possible resolution:

class A {
public:
   int func(){return 0;}
} a;

int (A::*pf3)() = &A::func;

class B {
public:
   void mf() {
      &B::mf;
   }
};

int main() {
   A a;
   &A::func;
}

About This Article

This article is a derivative work based on Compiler Error C2276 which is provided by MSDN Community Content - Visual C++.

 
 
 
 
Comments