Article ID: 155046
Article Last Modified on 6/2/2005
/* Compile options needed:
*/
class CMyClass
{
public:
void MyFunc() {int nVar = 100; }
};
void main()
{
CMyClass obj;
obj.MyFunc(); //Correct syntax - calls the member function
obj.MyFunc; //Typo, no (), should result in error but doesn't
//VC 5.0: correct warning C4551
CMyClass::MyFunc; // Typo, no &, should result in error but doesn't
&CMyClass::MyFunc; // Correctly treated as a pointer to member
// function.
}
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.
if (obj.MyFunc) { // Should be an error, instead always evaluates to
// TRUE. This code always executes.
}
else {
// This code will never be reached.
}
Additional query words: kbVC420bug kbVC400bug
Keywords: kbbug kbnoupdate kbcodegen kbcpponly kbcompiler kbfunctions KB155046