MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/lvhvgz/simple_c_initialization_flowchart/gpfa6av
r/cpp • u/konanTheBarbar • Mar 01 '21
65 comments sorted by
View all comments
Show parent comments
9
Yeah, it's called size(). The problem is that std::vector<std::string> v1{5} creates a vector with 5 empty strings, while std::vector<int> v2{5} creates a vector with 1 int with value 5.
size()
std::vector<std::string> v1{5}
std::vector<int> v2{5}
2 u/TryingT0Wr1t3 Mar 02 '21 Ah, ok, now I understood, thanks. It's, very confusing.
2
Ah, ok, now I understood, thanks. It's, very confusing.
9
u/mort96 Mar 02 '21
Yeah, it's called
size(). The problem is thatstd::vector<std::string> v1{5}creates a vector with 5 empty strings, whilestd::vector<int> v2{5}creates a vector with 1 int with value 5.