[菜鸟问题]类模板问题# Programming - 葵花宝典
d*e
1 楼
template
class MyClass
{
public:
class iterator
{
iterator operator ++ (int);
};
private:
....
};
// -- implementation
template
// -- next line got error message
MyClass::iterator MyClass::iterator::operator ++ (int)
{
iterator iter(*this);
........
return iter;
}
这个实现部分的函数头哪里有问题?我得到的g++错误信息:
error: expected constructor, destructor, or type conversion before "MyClass"
error: expected `;' before "MyClass"
class MyClass
{
public:
class iterator
{
iterator operator ++ (int);
};
private:
....
};
// -- implementation
template
// -- next line got error message
MyClass
{
iterator iter(*this);
........
return iter;
}
这个实现部分的函数头哪里有问题?我得到的g++错误信息:
error: expected constructor, destructor, or type conversion before "MyClass"
error: expected `;' before "MyClass"