举个例子:
定义了一个类的const实例,怎么让他也能调用非能调用非const成员函数class foo{public:void test1()
{cout << "I am not a const member function" << endl;}void test2()const
{foo *temp = (foo*)this;//注意这个转换!!!temp->test1();}};int main()
{foo f;f.test2();return 0;}