KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have the task to write own containers Linked_list and Array_list . I have one interface for them: typedef int value_type; class Container { public: class Iterator { public: Iterator(); Iterator(value_type* other); Iterator(const Iterator& other); Iterator& operator=(const Iterator& other); ... }; Container(); Container(const Container& other); ~Container(); virtual value_type& front() const=0; virtual value_type& back() const=0; virtual Iterator begin() const=0; // ... }; I did derived classes Linked_list and Array_list: class Linked_list:public Container { public: long int cur_size; List elem; static Link end_; class Iterator: public Container::Iterator { friend Linked_list; Link *p; }; Iterator begin() const; //overriding virtual function return type differs ... ... } I thinks it's all wrong. should nested class Linked_list::Iterator be a derived class? Is it possible to do this, if I can't change the interface?
Tags (comma-separated)
Save Edits
Cancel