Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CompuWizJacob

What?

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

I recently saw code like this: class Distance { public: Distance& in_metres( double value ); Distance& in_centimetres( double value ); Distance& in_feet( double value ); } My question is...how do you get away with using a class name as a return type? What does it do? How would you use it (examples would be helpful)? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
What do you mean by "get away with using a class name as a return type"? If the type is a class name, then you will be returning an object. In this case, you will be returning references to objects. Returning objects, in general, is no different from returning elementary types like integers. Use this feature when what you wish to return is an object.


[edited by - Miserable on November 4, 2002 7:10:04 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!