prog.cpp: In function ‘int main()’:
prog.cpp:72:14: warning: ‘auto’
changes meaning in C++11; please
remove it [-Wc++0x-compat] for (auto
&it : m) ^ prog.cpp:72:20: error: ISO
C++ forbids declaration of ‘it’ with
no type [-fpermissive] for (auto &it :
m) ^ prog.cpp:72:25: error:
range-based ‘for’ loops are not
allowed in C++98 mode for (auto &it :
m) ^ prog.cpp:74:24: error: request
for member ‘second’ in ‘it’, which is
of non-class type ‘int’ ans *=
(it.second + 1); ^
The difference-
C++98 (gcc 4.3.2)
map<int, int> m;
for (map<int, int>::iterator it = m.begin(); it != m.end(); it++)
{
ans *= (it->second + 1);
}
C++11 (gcc 4.8.1)
map<int, int> m;
for (auto &it : m)
{
ans *= (it.second + 1);
}