when should I use the new operator in C++

后端 未结 9 1997
有刺的猬
有刺的猬 2020-12-21 11:47

Say I have a class called Money which has parameters Dollars and Cents

I could initialize it in the followings 2 ways:

9条回答
  •  滥情空心
    2020-12-21 12:27

    You should use option two when you want a pointer to an object, and option one when you want a value.

提交回复
热议问题