我有一堂类似的课:
template <class T>
class bag
{
public:
private:
typedef struct{void* prev; struct{T item; unsigned int count;} body; void* next;}* node;
typedef struct{
node operator->() { return current; }
operator(){;} // <- i can not do that, right?
private:
node current;
} iterator;
//...
};
那么,如何为 bag::iterator 编写构造函数呢?
给它起一个好听的名字:-)
typedef struct NoName1 {void* prev; NoName1(){}; struct NoName2{T item; unsigned int count; NoName2() {}} body; void* next;}* node;
编辑:哈哈,抱歉,写错了,但原理是一样的:-)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)