3 ms·
> I declared p without explicitly mentioning the type of p. Instead, I used auto, which means "use the type of the initializer." So p is a vector<pair<string,in
by Sniffnoy 16y ago
> I declared p without explicitly mentioning the type of p. Instead, I used auto, which means "use the type of the initializer." So p is a vector<pair<string,int>>::iterator. That saves a fair bit of typing and removes the possibility of a few kinds of bugs. This is the oldest C++0x feature; I implemented it in 1983, but was forced to take it out for C compatibility reasons.
I don't understand this. Yes, "auto" is a reserved word in C... but couldn't Strostrup just have named it something else?
- jemfinch 16y agoUsing auto means 100% compatibility with existing C++ code. Using some other name would potentially require updates to existing code, which is bad.