moneitor Posted June 18, 2021 Share Posted June 18, 2021 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"); Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted June 21, 2021 Share Posted June 21, 2021 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++. 2 Quote Link to comment Share on other sites More sharing options...
moneitor Posted June 25, 2021 Author Share Posted June 25, 2021 Hey Alex, thanks very much for your detailed answer, really helped me a lot. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.