I've run into a small problem regarding polymorphism. I have a base class named TTT (tic tac toe), I then have 2 derived classes, OnlineGame, and OfflineGame. At the beginning of the program I make a pointer to TTT, then make it a new OnlineGame or OfflineGame depending on user input. My problem is that OnlineGame will need a function to accept the opponent's IP address. I made said function virtual, but now it's requiring me to declare it inside OfflineGame which is illogical to my design. Is there a better way to do this, or am I stuck defining a SetIPAddress for both classes?
This is my current code. It works, but I don't like it.
Code:class TTT { public: TTT(); void GetUserMove(); bool GameOver(); virtual void SetIPAddress(string &addr) = 0; virtual void GetOpponentMove(); }; class OnlineGame : public TTT { public: OnlineGame(); void SetIPAddress(string &addr); void GetOpponentMove(); }; class OfflineGame : public TTT { public: OfflineGame(); void SetIPAddress(string &addr); void GetOpponentMove(); };