How to do some stuff with values assigned in subscript operator?
问题 Suppose i've data array 0,0,1,1,2,2,5,5,7,7,2,2 as data member in class and i want to define subscript operator in such they [i] returns me 2*i element of array but also i want let user to set elements, so [i] = n, must be applied to both 2*i and 2*i+1. Is it possible to do it with showing to user only subscript operator? 0,0,1,1,2,2,5,5,7,7,2,2 [3] = 4; 0,0,1,1,2,2,4,4,7,7,2,2 another workarounds? and in general it may be not only two elements. 回答1: Indirectly, yes. You can return a