lundi 8 mars 2021

Creating constructor for the structure with union

This question from me solves the problem nicely.

However, it looks like I will need to create a constructor for that structure, because the following code:

std::vector<Foo> row;
row.push_back( Foo( 1, 1 ) );

errors out.

When I tried to add the constructor

Foo(int mytype, int myvalue)
{
    type = mytype;
    value.intvalue = myvalue;
}

it errors out saying

attempting to reference a deleted function

Do I need to define all 3 constructors?

Or there is something else?

TIA!!

Aucun commentaire:

Enregistrer un commentaire