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.
C + C++ Compiler: MinGW port of GCC
Build + Version Control System: SCons + Bazaar
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)
??????????
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)
So that you can write stuff such as:
Code:
x.func(1) = 2;
or in the case of operator[],
Code:
x[1] = 2;
C + C++ Compiler: MinGW port of GCC
Build + Version Control System: SCons + Bazaar
Bookmarks