Вопрос по c++ – константные эталонные параметры

73

Есть ли разница между следующими декларациями?

void somefunc(const Person &p);
void somefunc(Person const &p);
Error: User Rate Limit Exceeded Evan Teran

Ваш Ответ

5   ответов
4

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

91

no difference. const

const T &xconstreadonlyreadonly int x

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit ExceededconsistantError: User Rate Limit Exceeded
4

Person const & x

const Person & x

11

(See new link instead : )

[18.6] What does "const Fred& x" mean?

It means x aliases a Fred object, but x can't be used to change that Fred object.

[18.7] Does "Fred& const x" make any sense?

No, it is nonsense.

[18.8] What does "Fred const& x" mean?

Fred const& x is functionally equivalent to const Fred& x. However, the real question is which should be used.

Error: User Rate Limit Exceeded
47

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded

Похожие вопросы