C++ Object Instantiation

后端 未结 9 1983
孤街浪徒
孤街浪徒 2020-11-30 16:36

I\'m a C programmer trying to understand C++. Many tutorials demonstrate object instantiation using a snippet such as:

Dog* sparky = new Dog();
9条回答
  •  Happy的楠姐
    2020-11-30 16:52

    There is an additional reason, which no one else has mentioned, why you might choose to create your object dynamically. Dynamic, heap based objects allow you to make use of polymorphism.

提交回复
热议问题