What is the point of pointers?

后端 未结 12 1318
梦谈多话
梦谈多话 2021-02-01 18:49

What is the point of pointers in C++ when I can just declare variables? When is it appropriate to use them?

12条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 19:34

    Pointers are also great for passing a mutable argument to a function so that the caller can "see the change". You may wonder, "but why not use a reference?". I like Google's argument:

    http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Reference_Arguments

提交回复
热议问题