I've been programming enbedded systems in C for years, but I am trying to move to C++ as I do more Linux based applications.
I have a question regarding the correct way to design a class for a device driver. Specifically, I have an external device which communicates with a PC via a standard RS232 serial port. I want to define a class which can interact and control the device. I am already using libserial, a C++ class which provides me with basic RS232 send / receive capabilities, but this new class which I want to design should provide me with higher level control. So, what type of relationship should my new class have with the libserial class, if any? Should my new class inherit the libserial class, or do I just define an instance of a libserial object in my new class and use it? Or is there a better way?
That depends on whether or not you ever expect your class to be used (or substituted for) a libserial class. If yes, then make your class inherit from libserial. If not, then make libserial a private member object.