Both vector<int> vec(c, n)
and vector<int>(c, n)
call same constructor right?
vector<vector<int>> vec(2, vector<int>(2, 3)); // works fine
vector<vector<int>> vec(2, vector<int>v(2, 3)); // error
// error: expected primary-expression before ‘v’
And constructors don't return anything right? vector<int>(c, v)
here returned a vector
. If vector<int>(c, v)
and vector<int>vec(c, n)
are not same, then what's vector<int>(c, n)
and which constructor is it calling?
One answer described calling constructor without object would create anonymous object and would be destroyed after the immediate ;