Can you show us the context in which you're using this.
If you're doing something like
foo = foo;
Then I can see some deep problems in the code, like forever trying to append to itself.
Can you show us the context in which you're using this.
If you're doing something like
foo = foo;
Then I can see some deep problems in the code, like forever trying to append to itself.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I call the copy constructor in the program by declaring
Code:Sequence s2 = s; /*s is a linked with several nodes that i want to */copy into s2
You don't show start() or the Node constructor so I can't say what you do in there. However, in general, to copy the data from one list into another in the same sequence I'd first make sure that the old list isn't empty. If it is then no copying needed. If it isn't, since you keep track of the tail node, you don't need to run the list. If tail node is NULL then new list is empty so assign an initialized new node to head node and tail node. If tail node is not NULL, then assign an initialized node to tail->next and then assign tail->next to tail. What you do with cur and prev when you append each new node to tail is up to you. I'd repeat the process advancing from head node of old list to tail node of old list.
You're only born perfect.