我正在为一个类创建一个类图,该类在其头文件中有许多与此类似的定义。
1 2 3 4 5
const std::pair<Controller<_Tp,_Val>*, _Val>& getHighestBidder(_Tp obj) const;
我知道他们几个是做什么的,
2) says that this method will return a std::pair<Controller<_Tp, _Val>*, _Val>
3) gives the name of the function
4) defines the type of object this function accepts as a parameter
但是,1 和 5 是什么意思?
任何帮助/指点都会很棒。 谢谢
最佳答案
首先,请注意它不会返回 std::pair<Controller<_Tp, _Val>*, _Val>
, 它返回一个 std::pair<Controller<_Tp, _Val>*, _Val> &
,即对此类已存在对象的引用。
(1) 表示它是一个 const
引用一个对象;您不能通过此引用修改对象。
(5) 表示这是一个 const
成员函数,即它不会修改调用它的对象。
关于c++ - 这个 C++ 声明是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7422123/