k***e 发帖数: 556 | 1 template
void testTemp(vector& v) {
vector::iterator vit;
vit = v.begin( );
}
如上所示,我想用定义一个iterator与参数T有关,再做些操作,
结果有错。哪位能指点一下!谢谢! |
a**x 发帖数: 154 | 2 in this case the compiler has no idea about vector::iterator is a inner
class name or a static var in vector. so you need to use
typename vector::iterator vit;
to define a iterator |
k***e 发帖数: 556 | 3 楼主强!
【在 a**x 的大作中提到】 : in this case the compiler has no idea about vector::iterator is a inner : class name or a static var in vector. so you need to use : typename vector::iterator vit; : to define a iterator
|
g*******y 发帖数: 1930 | 4 楼主是你自己!呵呵
【在 k***e 的大作中提到】 : 楼主强!
|
k***e 发帖数: 556 | 5 晕 原来我一直理解错了楼主的含义
我以为我回的那个就是楼主
比如现在你就是
【在 g*******y 的大作中提到】 : 楼主是你自己!呵呵
|
l**a 发帖数: 43 | 6 嗯,effective STL 里面专门提到了typename的这个用途
【在 a**x 的大作中提到】 : in this case the compiler has no idea about vector::iterator is a inner : class name or a static var in vector. so you need to use : typename vector::iterator vit; : to define a iterator
|