The information in this article applies to:
SYMPTOMSLeaving the parentheses off a member function call, or leaving the ampersand ("&") off a reference to a pointer to a member function, does not result in a compiler error. CAUSEIn both cases, the Visual C++ compiler is incorrectly treating the reference as a pointer to the member function. A pointer to a member function cannot be referenced via a specific instance of a class (for example, "obj.MyFunct" in the sample code below). Instead, it must be referenced via the class name, scope operator and '&' operator (for example, &CMyClass::MyFunc in the sample code below). RESOLUTIONThe compiler should report an error on the line in question. STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. MORE INFORMATIONSample Code
Note that executing the program generated by the above code causes no run-
time errors, but executes MyFunc only once. The incorrect line has no
affect because it is treated exactly the same as the line following it.
Also note that this problem could seem to cause incorrect execution paths if the parenthesis are left off accidentally in the following type of construct:
Additional query words: kbVC420bug kbVC400bug
Keywords : kbCodeGen kbCompiler kbCPPonly kbVC kbVC400bug kbVC410bug kbVC420bug kbVC500bug kbVC600bug |
Last Reviewed: May 18, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |