I
I
IliaNeverov2021-07-02 19:34:22
C++ / C#
IliaNeverov, 2021-07-02 19:34:22

What exactly is made constant with this type definition?

What exactly is made constant in such a const std::vector<float>&vector entry, a reference or the vector itself?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-07-02
@IliaNeverov

Constant vector. You can only call constant methods, you cannot reassign or somehow change them.
But where can there be any misunderstanding here? In C++, you can never change what references refer to. const/not const can only be what it refers to.
Edit: I originally incorrectly called it a constant reference here, but for good reason, it's called a constant reference.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question