Storing a list of arbitrary objects in C++

前端 未结 13 2243
野趣味
野趣味 2021-02-06 08:29

In Java, you can have a List of Objects. You can add objects of multiple types, then retrieve them, check their type, and perform the appropriate action for that type.
For e

13条回答
  •  不要未来只要你来
    2021-02-06 09:00

    The short answer is... you can't.

    The long answer is... you'd have to define your own new heirarchy of objects that all inherit from a base object. In Java all objects ultimately descend from "Object", which is what allows you to do this.

提交回复
热议问题