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

后端 未结 5 1818
猫巷女王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:05

    To allow for operator overloading. They wanted operators to be overloadable both for objects and pointers, so they needed a way to refer to an object by something other than a pointer. Hence the reference was introduce. It is in "The Design and Evolution of C++".

提交回复
热议问题