Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualvdaras

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.

#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.

#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.

#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.

#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.

#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.

PARTNERS