I was in a bad need of a list type for holding named structs with in turn an arbitrary number of members of one same type, represented by a pointer. The full project code uses Qt (if that's important).
So I wrote this:
/*
* This should be used with T as a pointer type.
* Code gets really incomprehensible if T* value is used as member.
*/
template <typename T>
struct parameter_t {
QString name;
int count;
T value;
};
template <typename T>
class Parameters {
private:
typedef struct parameter_t< T > content_t; // beautification
public:
void addParam(const QString &name, T value, int count);
private:
std::list< content_t >* params;
};
typedef Parameters<float*> floatParameters; // beautification
Seems more than legit to me, for the actual implementation does compile error-free and stuff.
Now, from another location, I'm calling the following:
floatParameters* params = new floatParameters();
params->addParam("Ente", (float*) x, 1);
This results in compiler errors, including:
In function `...': HelperClasses.cc:(.text+0x225): undefined reference to Parameters<float*>::addParam(QString const&, float*, int)'
As you can clearly see, I'm creating floatParameters, so it's Parameters. In other words, the addParam member should translate to
void addParam(const QString &name, float* value, int count);
Why am I getting this error?