April 22nd, 2011, 05:49 PM
What can i say about these two's differences ?
reference opeartor(size s);
const_reference opeartor(size s);
April 22nd, 2011, 11:03 PM
One returns a reference, the other returns a const_reference
Actually, these are probably member functions, and the one that returns a const_reference probably should be declared const. Also, it is operator, not opeartor.
April 23rd, 2011, 02:30 AM
Thank you, i copied and pasted without rereading them. Now I fix them,
reference operator(size_type s);
const_reference operator(size_type s);
I guess I made a wrong question, mine should have been
int & func( int arg);
const int & func(int arg);
This simple! But i can only imagine that the return types between both are different, and it's vague to me that the const-ness in the latter is seemingly redundant (as for what sake one needs to change the returned value that is...already returned)
April 23rd, 2011, 02:53 AM
So that you can write stuff such as:
Originally Posted by Lucassergei
or in the case of operator,
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!