我有类Array
限定内部类const_iterator
内部类方法定义
template <class T, int SIZE = 100>
class Array
{
// my class here
public:
class const_iterator
{
// my class here
};
void insert(const_iterator position, int value);
};
template <class T, int SIZE /*= 100*/>
void Array<T, SIZE>::insert(const_iterator position, int value)
{
// impl
}
是正常,该类别的该外我已经定义的功能和作为第一个参数已经使用const_iterator position
键入而不是写入typename Array<T, SIZE>::const_iterator position
?这是否符合标准?如果在Array
类别之外还有另一个const_iterator
类别,该怎么办?
与您似乎暗示的不同,这与模板无关,同样的规则适用于非模板类。 – Holt