The difference between a C++ const reference variable and an ordinary variable

Asked 1 years ago, Updated 1 years ago, 102 views

For example, if you have a class called Point,

const Point Point::operator+(const Point& a) Wow const Point Point::operator+(Point a) What's the difference between

I only know that const Point& is faster because it is not a call by value, but a call by reference. Can anyone explain it in detail?

c++ const reference

2022-09-22 21:26

1 Answers

In the above case, const Point&a means that you cannot change the reference target of a.


2022-09-22 21:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.