转自:http://blog.csdn.net/djb100316878/article/details/42296203 当一个类只有const成员函数的时候,非const对象也可以调用const成员函数: [cpp] view plain copy print? // ConstTest.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; class A { public: A( void ) { } void func( void ) const { cout << "const version" << endl; } }; int _tmain(int argc, _TCHAR* argv[]) { //非const对象调用const成员函数 A obj; obj.func( ); //const对象调用const成员函数 const A obj_const; obj_const.func( ); system( "PAUSE" ); return EXIT_SUCCESS; return 0; } 上面的代码编译通过: