mercredi 8 juin 2022

Why push_back can use "({1,2})" to add multiple element for vector

I create a nested vector: vector<vector>test, and i want to add 2 elements to each inside vector. The above is my target, so I try two method

vector<vector<int>> test;

1: test.push_back({1,2});

2: test.emplce_back({1,2});

And I found the second method is wrong, Why?

Aucun commentaire:

Enregistrer un commentaire