When is C++ covariance the best solution?

后端 未结 6 717
温柔的废话
温柔的废话 2020-12-05 23:00

This question was asked here a few hours ago and made me realise that I have never actually used covariant return types in my own code. For those not sure what covariance is

6条回答
  •  隐瞒了意图╮
    2020-12-05 23:53

    Another example is a concrete factory which would returns pointers to the concrete classes instead of the abstract one (I've used it for internal use in the factory when the factory had to construct compound objects).

提交回复
热议问题