Jump to content

Noob Syntax question


Recommended Posts

Hi there,

I am learning C++ and just starting going through the HDK.

I saw this line and I can't understand what (OP_Network *) inside parenthesis is doing, I think I understand pointers and dereferencing enough, but that syntax I never saw before.

 

Hope you don't mind the simple question.

Thanks.
 

parent = (OP_Network *)OPgetDirector()->findNode("/obj");

 

Link to comment
Share on other sites

This is called casting in C/C++ more specifically a static upcast. This form is an old C style casing, C++ also adds static_cast syntax which does the same.

parent = static_cast<OP_Network*>(OPgetDirector()->findNode("/obj"));

Static means it's a compile time procedure and upcast means you get a pointer to the the parent base class which is higher in class hierarchy (therefore upcast). This is very common in C++.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...