C++ vectors of classes with constructors

前端 未结 3 592
后悔当初
后悔当初 2021-01-06 00:20
//Using g++ and ubuntu.
#include 
using namespace std;

Define a class:

class foo(){
(...)
foo(int arg1, double arg2);         


        
3条回答
  •  被撕碎了的回忆
    2021-01-06 01:10

    std::vector always create elements based on the default constructor which you haven't define in snippet above.

    the push_back method is facing a double free issue because you did not handle the copy constructor.

提交回复
热议问题