devxlogo

Ensure Your Overloaded Subscript Operator Returns an Object by Reference

Ensure Your Overloaded Subscript Operator Returns an Object by Reference

When you overload the subscript operator, remember that the non-const version of the overloaded operator should return an object by reference, not by value. Otherwise, you won’t be able to use it in assignment expressions:

 class IntArray{private://

devx-admin

Share the Post: