ListDBL is not a linked list. It's a node element of a linked list.
Your ListIterator is the linked list since it has the info for top, last current.
You should rename ListIterator to ListDBL and rename ListDBL to ListNode.
Then the ListNode should be a private embedded class within the new ListDBL.
That way your user won't be creating nodes but will have to use ListDBL methods to do it indirectly.
Next, an iterator is also an embedded class in the new ListDBL. Now for the begin() method all you need do is return an iterator with its position set to top. It should use ListDBL methods to get at top and last so there is only one place where top and last are maintained.
Maybe something like this:
[code=cpp]
class ListNode
{
public:
int value;
ListNode* next;
ListNode* previous;
};
class ListDBL
{
private:
ListNode*top;
ListNode*last;
ListNode*current;
public:
class Iterator
{
private:
ListDBL* theList; //for top and last
ListNode* iteratorPosition;
public:
void SetPosition(ListNode* arg);
};
Iterator begin();
};
As you work through this you will find you will need different iterator classes for const iterators, forward iterators, reverse iterators, const forward iterators, etc..
Check out the STL list template and see what they did.
I assume this is a scholastic exercise since all of this work is already done for you in the STL.
Once you get everything working with a data type of int in the node, then convert your code to a template.
class outer{
private:
class inner1{
private:
// private member variable
public:
//....
//variable,constructor and member functions
};
class inner2{
private:
// private member variable
public:
inner2 function1();
inner2 function2();
//....
//constructor and other member functions
};
public:
outer();
~outer();
void outer_function1();
//....
//other member functions
};
//....in main function..
outer obj;
obj.function1();
// Is it possible? If not, how can the public function of inner2 be called using object of outer class?(i have tried making friend class )
I've placed operator overloaded code (++/--/*etc) at the public section of the Iterator class (on the post of 'weaknessforcats') its but not working.
Could you please tell me something on it?
class outer
{
private:
class inner1
{
private:
// private member variable
public:
//....
//variable,constructor and member functions
};
public: //<-----------------------------------
class inner2
{
private:
// private member variable
public:
inner2 function1();
inner2 function2();
//....
//constructor and other member functions
};
public:
outer();
~outer();
void outer_function1();
//....
//other member functions
};
//....in main function..
int main()
{
outer::inner2 obj;
obj.inner2::function1();
}