Static members

Selection_035

The upper half of the area is for IC-7410, and the lower for Soft66LC4. The VFO frequencies are displayed, nameley, 7026.000kHz for IC-7410 amd 7020.000kHz for Soft66LC4.

When we click on the waterfall in the Soft66LC4 area, we want to change the VFO freqeuncy of IC-7410. So we need to get and set variables that do not belong to a class instance from which we want to manipulate. One method could be:

bool MyDrawingArea::on_draw(const Cairo::RefPtr<Cairo::Context> &cr) {

	s->asound_read();
	s->asound_fftcopy();
	fftw_execute(s->plan);

	int freq1 = s->get_frequency();
	int freq2 = s->get_other_frequency();

	char string[128];
	sprintf(string, "%9.3fkHz  %9.3fkHz", (double)freq1 / 1000.0, (double)freq2 / 1000.0);
}
class Sound : public AlsaParams {
public:
	virtual int  get_frequency      () = 0;
	virtual int  get_other_frequency() = 0;
	int  get_ic7410_frequency() const { return ic7410_frequency; }
	int  get_soft66_frequency() const { return soft66_frequency; }
}
class SoundIC7410: public Sound {
public:
	int  get_frequency  () override;
	int  get_other_frequency () override { return get_soft66_frequency(); }
}
class SoundSoft66: public Sound {
public:
	SoundSoft66(char* s, char* t);
	int  get_frequency       () override;
	int  get_other_frequency () override { return get_ic7410_frequency(); }
}
struct AlsaParams  {
	static int ic7410_frequency;
	static int soft66_frequency;
}

Redundant? Which style do you prefer?

//	int  get_other_frequency () override { return get_soft66_frequency(); }
	int  get_other_frequency () override { return soft66_frequency; }