Jump to content
  • Advertisement
Sign in to follow this  
ed209

how do I use pointer classes in parameters?

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

Advertisement
The term 'pointer class' is not something used very often.

If you're talking about a smart pointer class, such as std::auto_ptr or boost::shared_ptr, then their argument-passing semantics depend on which you use. All of them support pass-by-value, and some support passing by constant reference:

void function(std::auto_ptr<int> ptr);
void function(boost::shared_ptr<int> ptr);
void function(const boost::shared_ptr<int> & ptr);


If you're talking about passing a 'class pointer', you pass it like any other type (because a pointer to a class is a type like any other). For instance:
void function(std::string *ptr); // By value
void function(std::string *&ptr); // By reference

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!