Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error C2064

Error Message

term does not evaluate to a function taking 'number' arguments

A call is made to a function through an expression. The expression does not evaluate to a function pointer.

The following sample generates C2064:

// C2064.cpp
int i, j;
char* p;
void func() {
   j = i();    // C2064, i is not a function
   p();        // C2064, p doesn't point to a function
}

The following sample generates C2064:

// C2064b.cpp
struct C {
   void func1(){}
   void func2(){}
};
 
typedef void (C::*pFunc)();

int main() {
   C c;
   pFunc funcArray[2] = {&C::func1, &C::func2};
   (funcArray[0])();    // C2064
}

Possible resolution:

// C2064c.cpp
struct C {
   void func1(){}
   void func2(){}
};
 
typedef void (C::*pFunc)();

int main() {
   C c;
   pFunc funcArray[2] = {&C::func1, &C::func2};
   (c.* funcArray[0])();
}

The following sample generates C2064:

// C2064d.cpp
struct C {
   typedef void (C::*pFunc)();
   pFunc funcArray[2];
   void func1(){}
   void func2(){}
   C() {
      funcArray[0] = C::func1;
      funcArray[1] = C::func2;
   }
   void func3() {
      (funcArray[0])();   // C2064
   }
};

Possible resolution:

// C2064e.cpp
// compile with: /c
struct C {
   typedef void (C::*pFunc)();
   pFunc funcArray[2];
   void func1(){}
   void func2(){}
   C() {
      funcArray[0] = &C::func1;
      funcArray[1] = &C::func2;
   }
   void func3() {
      (this->* funcArray[0])();
   }
};

Community Additions

ADD
Show:
© 2015 Microsoft