Jump to content
  • Advertisement
Sign in to follow this  
Sabonis

Pointers as parameters

This topic is 4886 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

Just say you have a function that takes a pointer to an instanced class void MyFunc(cClass *MyClass) { //do something here } To access the class, would i place something like MyClass.PublicVariable = whatever; or MyClass.PublicFunction(); inside the function? I am not quite clear on the subject, but I keep getting errors that PublicFunction() must have struct/union/class to the left of the .operator. This means that I'm probably calling it wrong. Please help!

Share this post


Link to post
Share on other sites
Advertisement
YEah you need to derefence to get to the object the pointer is pointing to, so you can do this

(*MyClass).PublicFunction();
or
MyClass->PublicFunction();

Either work but people tend to use -> as its easier to read.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!