Klasa „nie jest szablonem”
Co oznacza ten błąd?
Generic.h:25: error: 'Generic' is not a template type
Oto rodzajowy.
template <class T>
class Generic: public QObject, public CFG, public virtual Evaluator {
Q_OBJECT
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_;
protected:
LCDText *lcdText_;
public:
Generic(Json::Value *config, int type);
~Generic();
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_; }
};
Czy problem polega na podklasowaniu innych klas? Próbowałem eksperymentu testującego tę teorię, ale nie spowodował tego błędu.
Edycja: Ok, więc kilku z was wskazało, że mogę być przekazany do przodu, deklarując Generic gdzie indziej, nie czyniąc go klasą szablonów. To prawda. A kiedy robię z niego szablon, otrzymuję inny błąd.
Property.h: 15: błąd: ISO C ++ zabrania deklaracji „Generic” bez typu
template <class T>
class Generic;
class Property : public CFG {
Generic *visitor; // line 15
bool is_valid;
QScriptValue result;
Json::Value *expression;
public:
Property(const Property &prop);
Property(Generic *v, Json::Value *section, std::string name, Json::Value *defval);
~Property();
bool Valid();
int Eval();
double P2N();
int P2INT();
std::string P2S();
void SetValue(Json::Value val);
Property operator=(Property prop);
};