Why does the compiler complain about a missing constructor when I'm just resizing my std::vector to a smaller size?

https://devblogs.microsoft.com/oldnewthing/20230711-00/?p=108408

8 points · 3 comments · view on lemmy.world

3 Comments

Arkaniol@programming.dev · 1 pts · 3y (1 reply)

Thank you. But why not just init the vector std::vector vect(56) And then resize 🧐

KRAW@linux.community · 1 pts · 3y

That vector constructor still requires a default constructor for the class of the object contained by the vector, so it's the same issue but different context.

rmam@programming.dev · 1 pts · 3y (1 reply)
[ removed ]
gracicot@programming.dev · 1 pts · 3y

I saw the article on my mastodon feed. When it's interesting I usually post it here