I am not sure. The problem is, I do not have enough information to decide if inheritance is needed here. You say it is, so okay, we can go with that. But then you apparently have a bad habit of creating A objects when you do not intend to, so perhaps you should be using A as just an interface.Originally Posted by -EquinoX-
Maybe we should work on your class design first instead of trying to fix this minor problem of why you end up with 0 printed instead of 2. So, what are the real names of A and B? What exactly are you trying to model?