Top "Const-reference" questions

C++ Return value, reference, const reference

Can you explain to me the difference between returning value, reference to value, and const reference to value? Value: Vector2…

c++ reference const-reference return-by-reference return-by-value
Does a const reference class member prolong the life of a temporary?

Why does this: #include <string> #include <iostream> using namespace std; class Sandbox { public: Sandbox(const string&…

c++ temporary ctor-initializer const-reference
Returning const reference to local variable from a function

I have some questions on returning a reference to a local variable from a function: class A { public: A(int …

c++ reference undefined const-reference
const-ref when sending signals in Qt

This is a thing that I never quite got with const-ref and I really hope that someone could explain it …

c++ qt signals-slots const-reference pass-by-const-reference
C++: Is it better to pass an enum as a value or as a const reference?

There are sort of two related questions here: A) How is enum implemented? For example, if I have the code: …

c++ enums performance const-reference
Passing rvalue reference to const lvalue reference paremeter

I am trying to understand C++11 rvalue references and how to use them for optimal performance in my code. Let's …

c++ c++11 lvalue rvalue const-reference
C++ return by reference and return by const-reference value is copied

I have some questions about returing a reference of a class member variable. I have the following code: #include <…

c++ reference return const-reference return-by-reference
How to return a const QString reference in case of failure?

consider the following code: const QString& MyClass::getID(int index) const { if (i < myArraySize && myArray[i]) { …

c++ qt const-reference