What is the use of const overloading in C++?

前端 未结 5 2005
盖世英雄少女心
盖世英雄少女心 2020-12-12 14:30

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 on

5条回答
  •  北海茫月
    2020-12-12 14:51

    You might want to use it to decide whether or not to return a const reference to an object or not. The STL's containers use a const overloaded begin() and end() function to decide whether to return a const_iterator or a normal iterator.

提交回复
热议问题