const T a {}; // constant of type T
const T& b {}; // ???
T c {}; // variable of type T
T& d {}; // error
What is the difference between a
and b
?
b
is a reference but I don't assign a object to it: in that instruction I initialize it by T constructor.
The address of b
is between the addresses of a and c, so it seems the b
and a
have no differences.
And if I can declare and initialize b
why d
gives compilation error?
I talked about a generic type T. I tested the code above either for primitive types and classes and the results are the same.