vendredi 4 octobre 2019

C++ type deduction with chain of auto declaration

I've got this exercise:

auto        p = 42;
auto const& q = p;
auto        r = q;
auto&       s = q;

What is the type of r and s?

This is my answer but I'm not very sure:

auto        p = 42;        // int
auto const& q = p;         // const int&
auto        r = q;         // int&
auto&       s = q;         // int&&

Aucun commentaire:

Enregistrer un commentaire