Guys,
sorry to ask, but I am trying to create a menu system to a bunch of parameter handlers whose intrinsic values could be int, float, enum etc.
After some thought, I have tried the following implementation:-
1. An abstract interface class, templated
2. several types of class to instantiate the template, e.g.
3. Declare FP_Parameters
And this all compiles quite nicely, so I can call their interface functions with varying data types. (I would have used overloading, it looks simpler, but overloading doesn't look at the return type.)
But here's the problem...
When I want to create an array of pointers to my parameter handlers so I can navigate the array as a dynamic menu...the base class (being templated) cannot be used as a data-type. But an array of base class pointers is exactly what I want here.
i.e.
Fails miserably
As this is my first C++ project, I reckon I am going about this the wrong way.
Any ideas?
Thanks
sorry to ask, but I am trying to create a menu system to a bunch of parameter handlers whose intrinsic values could be int, float, enum etc.
After some thought, I have tried the following implementation:-
1. An abstract interface class, templated
Code:
template <class T>
class ComParmIF{
public:
virtual T GetValue(void)=0;
// common to all types, does not neeed template class
virtual void GetValString(char *,int )=0;//parameter value as string max n chars
...
};
Code:
class FP_Parameter:public ComParmIF<float>{
public:
//stuff derived from ComParmIF
virtual float GetValue(void);
virtual void GetValString(char *, int);//parameter value as string max n chars
...
private:
float value;
};
3. Declare FP_Parameters
Code:
FP_Parameter RejectControl;
But here's the problem...
When I want to create an array of pointers to my parameter handlers so I can navigate the array as a dynamic menu...the base class (being templated) cannot be used as a data-type. But an array of base class pointers is exactly what I want here.
i.e.
Code:
ComParmIF *menuitem = &RejectControl;
As this is my first C++ project, I reckon I am going about this the wrong way.
Any ideas?
Thanks