Lets say for the sake of argument I have 3 classes, protocolA, protocolB and connect.
protocolB inherits from protocolA and has exactly the same interface. connect is a GUI connection dialog that takes a pointer to protocolA and runs ->connect() on that.
The problem I am having is that I don't know which protocol will be used until the user selects it in the connection dialog, so when the class is initialised before the GUI is even created, it is created as a protocolA.
My question is, is it possible to convert the pointer from protocolA to protocolB in the connect class if so required?
Note that it is accessed through pointers in the entire program, including main where it is created using new.
If this isn't possible, can anyone suggest a better solution?