template problem in c++
hey guys. i'm having some problems in using templates in c++. here is the code i'm trying to compile. i'll send a shrinked version.
Code:
#include<list> when i change the return type to Code:
list<pair<int, int> >::iterator thx in advance. |
The problem is that the compiler can't know that
list<pair<K, V> >::iterator is the name of a type. Even though the compiler has at that point seen the whole definition of list so you would expect it to know iterator is a name of a type inside list, the C++ standard has rules that prevent it from knowing. In this situation, I strongly prefer to use several typedefs to break up the ugly declarations. So you could fix your problem just by adding the keyword typename to your declaration. But I personally think it is very ugly to use typename that way anywhere other than right after the keyword typedef I haven't tested any of this, but I think it is right: Code:
#include<list> Code:
#include<list> |
thx, that solved my problem!! and thx for the extra explanation.
|
All times are GMT -5. The time now is 02:47 AM. |