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
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
相关文章推荐
- How to initialize a static const map in c++?
- const volatile, register volatile, static volatile in C++
- const in C++
- Meaning of “const” last in a C++ method declaration?
- Const in C++
- 【ThinkingInC++】40、论const对函数返回值的作用
- const in C/C++
- const in c++
- 【ThinkingInC++】39、const的传递和返回地址
- make it clear how to use const in C++
- thinking in c++ 之const小结
- effective c++ prefer const,enum, inline to #defines
- Function Overloading in C++
- C++中三大修饰符 static const inline
- C++ 使用#define带来的问题及解决方法(const enum inline)
- 【ThinkingInC++】42、类里的const
- 【ThinkingInC++】46、特定的数据成员可以在一个const对象里被改变
- about const in C++
- const in C/C++
- const in C++