Hello, tell me how to properly store a lot of device settings. There is a program for the device, where there are many-many channels (1,2,3, ... up to 20), well, for each channel there are different parameters (signal type, upper limit, lower limit, upper limit of measurements, lower limit of measurements and etc ....). Accordingly, each parameter for each channel should be constant, I created a class:
Channel1.h :
class Channel1Options { public: QString GetUnitsName(); int GetSignalType1(); int GetSignalType(); int GetLowerLimit(); int GetHigherLimit(); int GetLowerMeasureLimit(); int GetHigherMeasureLimit(); void SetSignalType(int newsignaltype); void SetLowerLimit(int newsignaltype); void SetHigherLimit(int newhigherlimit); void SetLowerMeasureLimit(int newlowermeaslimit); void SetHigherMeasureLimit(int newhighermeaslimit); void SetUnitsName(QString newunit); // приватные переменные настроек канала 1 private: static int signaltype; static int lowerlimit; static int higherlimit; static int lowermeasurelimit; static int highermeasurelimit; static int measureperiodsecond; static QString unitsname; }; Channel1.cpp :
void Channel1Options::SetUnitsName(QString newunitname) { unitsname = newunitname; } QString Channel1Options::GetUnitsName() { return unitsname; } Next, for the second channel, I make a class that inherits the class for the first channel:
Channel1.h :
class Channel2Options : public Channel1Options { // переменные настроек канала 2 private: static int signaltype; static int lowerlimit; static int higherlimit; static int lowermeasurelimit; static int highermeasurelimit; static int measureperiodsecond; static QString unitsname; }; I want to create objects for the class of the first and second channels, we can work with their parameters, respectively
main.cpp :
Channel1Options a; Channel2Options b; a.SetUnitsName("Volts"); b.SetUnitsName("Ampers"); qDebug() << a.GetUnitsName(); qDebug() << b.GetUnitsName(); In the desired embodiment, the output should be:
"Ampers" "Volts"
But in fact:
"Volts" "Volts"