What exactly was the rationale behind introducing references in c++?

后端 未结 5 1816
猫巷女王i
猫巷女王i 2021-01-03 17:26

From the discussion that has happened in my recent question (Why is a c++ reference considered safer than a pointer?), it raises another question in my mind: What exactly wa

5条回答
  •  北海茫月
    2021-01-03 18:17

    You need them for operator overloading (of course we can now go down the rabbit hole of "what was the rationale for introducing operator overloading?")

    How would you type std::auto_ptr::operator*() without references? Or std::vector::operator[]?

提交回复
热议问题