Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Turnipo

Is this object valid?

This topic is 5914 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Folks, Here is a small snippet of code. Node *start = new Node(x1, y1, NULL, NULL); Node *end = new Node(x2, y2, NULL, NULL); Node *CurrentNode = start; Here I have created 2 nodes. I want to have a pointer to the node currently being processed. I have initialised the pointer to the start node. Have I done this correctly? Regards. -------------------------- Why are you driving like a hammerhead?

Share this post


Link to post
Share on other sites
Advertisement
You have the right idea. We can''t tell you if the specific code is correct because that depends on the ctor parameters like Elixir hinted at, but if it compiles (or you simply know the parameters are fine), then yeah, everything looks in order.

Share this post


Link to post
Share on other sites
Here is my Node constructor.

Node::Node(unsigned int x,unsigned int y,Node *parent,Node *child)
{
this->x = x;
this->y = y;
this->parent = parent;
this->child = child;
}

Share this post


Link to post
Share on other sites
While not technically wrong, it would look nicer if you changed the names of the parameters so that you wouldn''t have to use the this pointer.

Share this post


Link to post
Share on other sites
@Zipster: Thats just personal preference. I like it more the way he did it. But mainly it''s symptomatic of VC6 or other code-autocompletion.
I like it more because whenever I revisit the code after a long time I keep asking myself where a variable was defined, if not written like that.

---------------------------
I may be getting older, but I refuse to grow up

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!