1

There is a certain class hierarchy and I would like to have another hierarchy having a class corresponding to every class in the former hierarchy. Note that the structure of the second hierarchy isn't as neat or as similar as the original hierarchy.

As an illustration, I have a Game hierarchy that has different games like CricketGame, TestCricketGame, BasketBallGame etc., and there must exist a CricketGamesContainer, TestCricketGamesContainer and BasketBallGamesContainer in the other hierarchy. Is there a way of ensuring that for every class in the Game hierarchy the programmer is forced to write a class in the Container hierarchy? That is, say, the code doesn't compile otherwise.

Enigman
  • 640
  • 3
  • 9
  • 21
  • Sounds quite unlikely that you could make the compiler enforce this.. For clarity, are you doing this in java or c++? Or do you not care as long as it is possible using one of them? – Illidanek May 01 '14 at 11:56
  • As I've stated in the question heading, it's in C++ :) And we will have to stick to that. – Enigman May 01 '14 at 18:07
  • 1
    If at all possible, avoid the parallel hierarchies altogether, as [outlined in this question](http://stackoverflow.com/questions/696350/avoiding-parallel-inheritance-hierarchies). – Mazyod Sep 04 '14 at 13:09

0 Answers0