Let's say I do have an interface IControllable, 3 classes inherits that interface: MachineControllable, LightControllable, OtherControllable which has some specific data and methods to them.
Now I do want to have only one container of all IControllable, so I do create a vector container.
vector<IControllable> allControllables; // and put all the MachineControllable,
//LightControllable, OtherControllable here by the IControllable interface class.
But the problem now, that I can only use what the IControllable defines, not the specific data and methods of specific Controllable.
Should I have seperate containers for each Controllable, or how my logic is wrong in terms of OOP ?
No, your logic is OK. The problem is, you can't instatiate an abstract class.
You should have a container keeping pointers to the
IControllableinterface, like:or
or