Essence: I create an array of objects of the user class. And I would very much like each element to know its number. It is relative to a particular array. It is clear that the initial constructor is used when initializing the array. But how to redefine it to solve the problem? After all, Array itself is not inherited.
- only manually update the index when saving an object to an array - Grundy
- 3most likely you don't need an array, but you need your own collection, and you can do anything in it - Grundy
- 2Eh, how does an element know its index? To do this, in the element this very index needs to be stored somewhere. Tell better for what it is you, what problem you want to solve this way. - VladD
- use the list, the same array as a matter of fact, only where with more ample opportunities - Garrus_En
- @VladD create an array with auto-sorting of elements when one of them changes - wemon
|