我有一个这样的课:
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;
编辑:大声抱歉,写错了一个,但原则是一样的:-)