jeudi 14 février 2019

Sort a container of base and derived objects by 1. type or 2. by a data member of a derived object

Sorting objects by a common attribute is fairly straightforward but what if one had to :

  1. sort a base container of base & derived objects by type, for example, derived objects will be grouped together and vice versa for base objects.

  2. sort a base container of base & derived objects by an attribute that only exists in the derived object.

Apart from storing the objects separately, what other ways are there?

Aucun commentaire:

Enregistrer un commentaire