您的位置:首页 > 编程语言 > C语言/C++

const overloading in C++

2011-09-07 16:23 381 查看
In C++, a function's signature depends partly on whether or not it's const. This means that a class can have two member functions with identical signatures except that one is const and the other is not. If you have a class like this, then the compiler will
decide which function to call based on the object you call it on: if it's a const instance of the class, the const version of the function will be called; if the object isn't const, the other version will be called.

In what circumstances might you want to take advantage of this feature?

 

http://stackoverflow.com/questions/251159/what-is-the-use-of-const-overloading-in-c
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息