Variable Declicration to Hold Multiple Different (But Similar) Classes?

Not sure if this is even possible, but how would I declare a variable such that it would be able to hold either an EthernetClient object or a WiFiClient object (or any of the similar interface types)? I’m writing a api wrapper and would like to be able to pass it a client object so that my library is compatible with anything that has a similar client style interface.

WiFiClient and EthernetClient are both subclasses of the 'Client' class, so you can use a pointer of type Client to store a pointer to an instance of either of them.

An example:

byte isConnected(Client* theClient){
  return theClient->connected(); //notice the '->' instead of the '.' as it's a pointer
}

...

EthernetClient someInstance;
if (isConnected(&someInstance)){
  Serial.print("boo");
}
WiFiClient someOtherInstance;
if (isConnected(&someOtherInstance)){
  Serial.print("boo");
}

There is only one caveat to doing this and that is that you can only use functions which are declared in 'Client'.

That make that really easy. Thanks Tom!