I'm creating a little container class, but I have a design doubt. I'll post here some example code:
I had then to use a variable of type node inside a function of iterator and const_iterator, so I changed my class like this(friend doesn't seem to work for types, right? only for variables when the type is already known):Code:template<T> class useful_class { public: void some_func() { node *node_; ... } ... class iterator {}; class const_iterator {}; private: struct node {}; ... };
Not really elegant, but not really a big problem either.Anyway, is it solvable in any other(better) way?Code:template<T> class useful_class { public: struct node {}; void some_func() { node *node_; ... } ... class iterator { public: iterator &operator++() { node *node_; ... } }; class const_iterator { public: const_iterator &operator++() { node *node_; ... } }; private: ... };



LinkBack URL
About LinkBacks



