Setting up an OLED display instance in a library

I need some help in setting up a library for a menu system.

The library will be used to update a 128x64 OLED display, and will display scrollable menu options on the device.

In my normal sketches, to create the oleddisplay instance I use:-

//---
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
#define OLED_MOSI 9
#define OLED_CLK 10
#define OLED_DC 11
#define OLED_CS 12
#define OLED_RESET 13
Adafruit_SH1106 oleddisplay(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

In setup() I use:-
oleddisplay.begin();
oleddisplay.clearDisplay();
oleddisplay.display();
//---

The pin assignments for the oled will change from sketch to sketch, so I can't hard code them in the library.

When I use my menu library, I assume I need to pass the SH1106 display pin numbers to the constructor or to the begin function. I then need to get the library to create the 'oleddisplay' object according to those pin assignments.
The library functions will update the oled device using oleddisplay.
The oleddisplay object will be only be used privately and globally within the library.

I can't figure out how or where to set up oleddisplay in the h and cpp files, and would be grateful if you could point me in the right direction.

Thanks for looking.

Steve

Hello

One way is to do something like this : NK8qen - Online C++ Compiler & Debugging Tool - Ideone.com

Another way : ICNRM8 - Online C++ Compiler & Debugging Tool - Ideone.com