我是C++新手。你能告诉我为什么std :: vector :: front有两个定义,它们有什么不同,以及它们是如何被调用的?为什么std :: vector :: front有两个定义? (C++)
功能似乎有两种定义,
- 参考前面();
- const_reference front()const;
当我在Web上查找函数时,我注意到了这两个定义。以下两个网站似乎说了相同的两个定义。
http://www.cplusplus.com/reference/vector/vector/front/
http://en.cppreference.com/w/cpp/container/vector/front
这是为了保持常量的正确性。一个用于非常量,一个用于常量。 –
@GillBates:你的名字让我笑了起来。 – 2016-09-22 14:24:49