Hello. I am writing software for embedded systems. I started to switch from C to C ++. Developing libraries on c ++, I noticed that part of the code in each of my libraries is repeated, namely, part of the binding of each library to the total non-volatile memory and energy dependent memory available from outside. As a result, a common table of data available via the ModBus protocol and so on is formed.
Thus, by adding a library to a project, its data becomes available for modification and reading via ModBus.
The question is, how is it better to organize the code so that you do not need to write the same code for each new library?
I started by creating a base class for all libraries in which functions common to all libraries are described, and each of the libraries inheriting the base class describes its own particular virtual methods. It turned out that all created objects of any class inherited from the base class are placed in a common queue, in which their virtual functions are called in Main.
However, I feel that I am doing wrong and there is a better way. Tell me how best to implement this task?