Hi
I am thinking about the assignment operator...
Basically if I want to overload it I code something like this :
now the reason i return a const ref, is that i don't allow the user to do non-sence thing like the following :Code:class test{ public: const test& operator=( const test& src ) { return *this; }; };
i just ommited the self assignment checkingCode:test a, b, c; (a = b) = c;, cuz i wanna talk about the returned ref only in this thread....
which style do you use ? this :
orCode:test& operator=( const test& src )
Code:const test& operator=( const test& src )
I know that with non-const returned ref we could code somthing like this :
is this a good style ?Code:void func( test& obj ){}; . . . func( a = b );





Reply With Quote
