Scott Scott - 5 months ago 30
C++ Question

Class 'is not a template type'

What does this error mean?

Generic.h:25: error: 'Generic' is not a template type

Here's Generic.

template <class T>
class Generic: public QObject, public CFG, public virtual Evaluator {
std::string key_;
std::vector<std::string> layouts_;
std::vector<std::string> static_widgets_;
std::map<std::string, std::vector<widget_template> > widget_templates_;
std::map<std::string, Widget *> widgets_;
int type_;
LCDWrapper *wrapper_;

LCDText *lcdText_;

Generic(Json::Value *config, int type);
void CFGSetup(std::string key);
void BuildLayouts();
void StartLayout();
int GetType() { return type_; }
//T *GetLCD() { return lcd_; }
LCDText *GetLCDText() { return lcdText_; }
virtual void Connect(){};
virtual void SetupDevice(){};
std::map<std::string, Widget *> Widgets();
std::string CFG_Key();
LCDWrapper *GetWrapper() { return wrapper_; }


Is the problem that it subclasses other classes? I tried an experiment testing that theory, but it didn't produce this error.

Edit: Ok, so a couple of you guys pointed out I could be forward declaring Generic elsewhere without making it a template class. That's true. And when I make it a template, I get another error.

Property.h:15: error: ISO C++ forbids declaration of 'Generic' with no type

template <class T>
class Generic;

class Property : public CFG {
Generic *visitor; // line 15
bool is_valid;
QScriptValue result;
Json::Value *expression;
Property(const Property &prop);
Property(Generic *v, Json::Value *section, std::string name, Json::Value *defval);
bool Valid();
int Eval();
double P2N();
int P2INT();
std::string P2S();
void SetValue(Json::Value val);
Property operator=(Property prop);


I'm not sure if this is your problem, but you can't subclass QObject with a template class.

Here is more information about that.