Classes, Inheritance, and device drivers

Hi,

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?

Thanks,
Scott
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.

You might want to read up on inheritance over at

http://www.parashift.com/c++-faq-lite/

It gives _very_ solid advice and reasons why to do/not do things a certain way.

Hope this helps.
scott my condition is exactly as you .....

i am also in search of some magic stick for c++

i know basic concepts but advance concepts like templates and STL is too difficult to remember while coding ...

you should use it as derived class.
Topic archived. No new replies allowed.