本文介绍了什么是const对象和const函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是const对象和const函数.
What is const object and const functions.
推荐答案
class CWnd
{
public:
void ConstFunction() const
{
// It's a const function, you can change the member of this pointer.
}
void UnConstFunction()
{
}
}
// It's a const object, you can't change the member of wnd, you can't call the un-const function of
// CWnd, such as UnConstFunction.
const CWnd wnd;
添加了代码块[/编辑]
Code block added[/Edit]
这篇关于什么是const对象和const函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!