0

A few examples:

const char* chars = returnschars();

const std::string str(chars);
const std::string& str_ref(chars);

Is there a difference between str and str_ref and what exactly is different?

const auto& foo = createfoo();
const auto& bar = createbarbasedonfoo(foo)
const auto& pair = std::make_pair(foo, bar);

Why does this work?
Who owns the object that foo is referencing?

const int& i = 15;
const int j = 15;

Again, is there a difference between i and j and what exactly is different?

 

Could I just only use const references instead of const?

Rasmus-123
  • 81
  • 7

0 Answers0