Jump to content
Sign in to follow this  
moneitor

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");

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Hey Alex, thanks very much for your detailed answer, really helped me a lot.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×