HI all, I am creating a doubly circular linked list using dummy node. I have a variable "anchor" of type class, which I have to use in dummy node.
Following is my Data Structure .. Probably there could be some mistakes.
I am trying to create a new node in constructor but did not get success ! PLease suggest some idea. !
class My570List;
class My570ListElem
{
public:
int data;
//My570ListElem();
private:
friend class My570List;
My570ListElem *next;
My570ListElem *prev;
Line -> node=new My570List();
This is keep on repeating when I saw in debugger ! I tried to create new inside the class .. that did not work; also tried to create outside the class and before constructor .. that wont work either. Segmentation Fault while creating the node.
you cannot create an instance of the class itself in its constructor. It's an infinite recursion.
the constructor calls the constructor calls the consturctor...
avoid circular dependency. that's almost impossible to master
That's just a convention, using a `circular' list will prevent invalid pointers.
Besides, the dummy node approach will not use a pointer, but an object (the dummy)