C++, array of objects without

后端 未结 9 1727
渐次进展
渐次进展 2020-12-08 07:34

I want to create in C++ an array of Objects without using STL.

How can I do this?

How could I create array of Object2, which has no argumentless constructor

9条回答
  •  自闭症患者
    2020-12-08 07:53

    You can do what std::vector does and create a block of raw memory. You then construct your objects which don't have a default constructor in that memory using placement new, as they are required. But of course, if you do that you might as well have used std::vector in the first place.

提交回复
热议问题