avatar
z*y
1
const int &func (int a, int b) const;
what is the meaning of first "const" and last "const"?
what is the meaning of "&"?
avatar
d*x
2
...

【在 z*y 的大作中提到】
: const int &func (int a, int b) const;
: what is the meaning of first "const" and last "const"?
: what is the meaning of "&"?

avatar
H*s
3
This function returns a constant integer reference, this member function is
a constant function that won't change any member variables of the associated
class.
avatar
w*s
4
你这得从头学。
avatar
A*i
5
一直认为函数前的const绝对是有人故意造出来害人的,因为完全没有用处。貌似C++
prime也提过这个,但是每次面试总考,这绝对是个阴谋
avatar
l*u
6
同意。
return constant的function,应该是某个"蛋疼帝"想出来滴 :)

【在 A*****i 的大作中提到】
: 一直认为函数前的const绝对是有人故意造出来害人的,因为完全没有用处。貌似C++
: prime也提过这个,但是每次面试总考,这绝对是个阴谋

avatar
q*m
7
c++ overloading 不检查 return type 吧。

【在 l*********u 的大作中提到】
: 同意。
: return constant的function,应该是某个"蛋疼帝"想出来滴 :)

avatar
H*s
8
你们错了, 这里我只举一个简单例子说明一下,return constant reference
绝对不是多此一举。
class A{

Object theObj;
public:
const Object & getTheObj(); //the Obj won't get changed when calling this
//function
};

【在 l*********u 的大作中提到】
: 同意。
: return constant的function,应该是某个"蛋疼帝"想出来滴 :)

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。