Microsoft KB Archive/263589

= BUG: Pointer to Member Allows Non-const Method Call on const Object =

Article ID: 263589

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q263589



SYMPTOMS
No error or warning message is generated if you try to call a non-const member function on a const class object by using a member pointer.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
The following sample code demonstrates the bug: //test.cpp //compiler option needed: none class A { int m_val; public: A(int i=0) : m_val(i) {} void Add(int val) { m_val+=val; } }; int main {   void(A::*MFptr)(int) = &A::Add; const A ca;     //const object (ca.*MFptr)(5); //no error here return 0; }

Keywords: kbbug kbcpponly kbcompiler KB263589

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.