9 years, 3 months ago.

Different objects, same functions

Hi to everyone, I'm a c++ rookie with a little (?) problem.

I write a little library using a Serial object, something like:

Serial pc(SERIAL_TX, SERIAL_RX); 
Screen sc(&pc);

where Screen is a class like:

class Screen
{
public:
    Screen(Serial* ps);

    void banner();
    void pressed();
...

and Screen is

Screen::Screen(Serial* ps)
{
    _ps=ps;
}

Now I try to use BufferedSerial Lib but I need my lib working with Serial and BufferedSerial . Something like

Serial pc(SERIAL_TX, SERIAL_RX); 
Screen sc(&pc);

or

BufferedSerial pc(SERIAL_TX, SERIAL_RX); 
Screen sc(&pc);

Is it possible?

Thank you Max

Be the first to answer this question.