What can i say about these two's differences ?
reference opeartor[](size s);
const_reference opeartor[](size s);
:confused:
Thank you.
Printable View
What can i say about these two's differences ?
reference opeartor[](size s);
const_reference opeartor[](size s);
:confused:
Thank you.
One returns a reference, the other returns a const_reference :p
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.
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)
??????????
So that you can write stuff such as:Quote:
Originally Posted by Lucassergei
or in the case of operator[],Code:x.func(1) = 2;
Code:x[1] = 2;