Archived

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

CompuWizJacob

What?

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
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