lundi 1 juillet 2019

How to initialize a vector in the constructor?

How to initialize a vector in the constructor? I want to initialize the vector properties in the constructor Doom but I get this error:

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

//.h

class Doom
{
    public:
        Doom(std::string  label,  vector<std::string> * properties);

//.h

class Div:public Doom
{
public:
    Div();
    string addPropertie(string );
    vector<std::string> *c;

    string d;
protected:

private:
};

//.cpp

Div::Div():Doom(Div::d, Div::c)
{
cout<<"DIV"<<endl;
}

Aucun commentaire:

Enregistrer un commentaire