reference different display objects

Im developing something that will run with 2 different displays. While developing, I want to run them both, without doubling my code.

The displays are different and of a different class.
Yet I want to do something like this:

Adafruit_SharpMem sharp(somepin, anotherpin, thirdpin, 144, 168);
GxEPD_Class waveshare(io, 22, 17); 

void loop() {
 
 paintlcd(200,200,waveshare) 
 paintlcd(144,168,sharp)

}

void paintlcd(int xres, int yres, disptype &dispref) {
  
  dispref.fillRect(0,0,xres,yres,BLACK);
  
}

As you can see, I think this requires pointers, thats how far I got with googling (should I mention, Im a noob?) but I dont know how to declare 'distype' ? Or how else do I do this?

I dont know how to declare 'distype' ?

Since paintlcd() is a function, it can only take one type. If the classes share a common base class, use can use that base class as the type. If not, you can't have one function that can use either device.

Post links to both libraries if you need help determining if they share a base class.

This is the adafruit sharp library:

and this for the eink display:

(in particular, its the GxGDEP015OC1)

thanks a lot!

Adafruit_SharpMem derives from Adafruit_GFX.

GxGDEP015OC1 derives from GxEPD which derives from Adafruit_GFX.

So, you can define your function to take a reference to a Adafruit_GFX object, and make it function for either class, as long as you do not need to use the features that make a Adafruit_SharpMem different from a Adafruit_GFX or the features that make a GxGDEP015OC1 different from a Adafruit_GFX.

Brilliant, I'll try that. And yes, there are some functions specific to one or the other, but I can manually handle those. Thanks!