On 2016年12月02日 21:34, Jonathan Wakely wrote:
On 2 December 2016 at 13:10, chenzero wrote:
currently, I am confused because the same code can be compiled in C++Builder
and Visual studio 2008, but not gcc.
So read the link, it explains the problem.
The code is not valid according to the C++ standard, so GCC is
correct, and your older Borland and Visual Studio compilers are wrong.
Thanks a lot for your help!
the standard way for code is: add a "typename" before the iter declaration.
template<typename K, typename V>
static void getKeySet(std::map<K,V>& m, std::vector<K>& ks) {
typename std::map<K,V>::iterator iter;
for(iter=m.begin();iter!=m.end();iter++) {
ks.push_back(iter->first);
}
}