Sunday, March 9, 2014


C++11 introduced the ability to "ref-qualifier" methods. The most known qualifier is the const one:

however now is also possible to ref-qualify *this

let see how this can be of any use. Immagine to have a factory building heavy objects and returning them by copy this way:

in the following scenario we can avoid an useless copy:

we can avoid the copy if Jumbo is movable overloading the method getJumboByCopy in case the object on which I'm calling it is a temporary:

To be honest the example shows a scenario with other problems than the one mentioned (for instance if the object Jumbo is so big why permitting the copy then?) but I hope you got the idea.


Affity Solutions said...

Thanks for your ideas. You can also find the details on Affity Solutions, at the C++ Development. The main object of the Affity Solutions is to provide quality web services and is among the few software development company in Nagpur.

Ahmad Urpan Rifai said...





awais kamran said...

Informative post. Thanks for sharing.
C++ Urdu Tutorial