My bet is that sooner123 doesn't understand the pointer concept very well.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes the sentinel pointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.
Show differencesHistory of post edits
#5vdaras
Posted 03 December 2012 - 08:48 AM
My bet is that sooner123 doesn't understand the pointer concept very well.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes the sentinel pointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes the sentinel pointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.
#4vdaras
Posted 03 December 2012 - 08:47 AM
My bet is that sooner123 doesn't understand the pointer concept very well.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes the sentinel pointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes the sentinel pointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.
#3vdaras
Posted 03 December 2012 - 08:47 AM
My bet is that sooner123 doesn't understand the pointer concept very well.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes thesentinelpointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes thesentinelpointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.
#2vdaras
Posted 03 December 2012 - 08:46 AM
My bet is that sooner123 doesn't understand the pointer concept very well.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes thesentinelpointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes thesentinelpointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.
#1vdaras
Posted 03 December 2012 - 08:46 AM
My bet is that sooner123 doesn't understand the pointer concept very well.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes thesentinelpointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.
sooner123,
[source lang="cpp"]Node* sentinel = new Node;[/source]
This line of code creates a new object of the Node class on the free store and makes thesentinelpointer reference that object.
So in order to make your pointer reference the pre-existing Node object, which you wanted to do in the first place, you just need this
[source lang="cpp"]Node* sentinel = list;[/source]
Sorry for stating the obvious to the vast majority of you, but from what I got from sooner123's responses, the op probably didn't understand why allocating the
new node was unnecessary.