Coming from a background of PHP and Java I want to do things in C++ which are not as easy as I had hoped.
Let's say I have a header file (which I see as an Interface) containing the class Sensor
I have multiple types of sensors but they all have the basic functionality such as
- initialize
- read
- write
However, they are all implemented in a different way for each sensor.
In PHP I would be able to use IoC and dependency injection to bind a specific implementation to an interface.
How can I extend the "interface"/header with the specific implementation for each sensor?
I imagine having a file structure like so:
sensor.h
sensor1.cpp
sensor2.cpp
Where the .cpp
files are all different implementations for the Sensor
interface.
My compiler is compatible with C++11 and I prefer to do things the "new" way.