c++ - Can't create QList with custom class -
i'm trying create qlist of custom class objects, got error:
error: c2923: 'qlist' : 'read' not valid template type argument parameter 't'
my code (user header):
#ifndef user_h #define user_h #include <qstring> #include <qlist> #include "read.h" class user { protected: int id; qstring username; qstring password; qlist<read> readbooks; bool accountdeleted; bool admin; public: user(); user(int id, qstring username, qstring password, qlist<read> readbooks, bool accountdeleted, bool admin); ~user(); const int getid(); void setid(int id); const qstring getusername(); void setusername(qstring username); const qstring getpassword(); void setpassword(qstring password); const qlist<read> getreadbooks(); void setreadbooks(qlist<read> readbooks); const bool isaccountdeleted(); void setaccountdeleted(bool accountdeleted); const bool isadmin(); void setadmin(bool admin); }; qdatastream &operator<<(qdatastream &out, const user &user); qdatastream &operator>>(qdatastream &in, user &user); #endif // user_h
and qt gives me error list:
...\user.h(13) : error c2065: 'read' : undeclared identifier ...\user.h(13) : error c2923: 'qlist' : 'read' not valid template type argument parameter 't' ...\user.h(18) : error c2065: 'read' : undeclared identifier ...\user.h(18) : error c2923: 'qlist' : 'read' not valid template type argument parameter 't' ...\user.h(27) : error c2065: 'read' : undeclared identifier ...\user.h(27) : error c2923: 'qlist' : 'read' not valid template type argument parameter 't' ...\user.h(28) : error c2065: 'read' : undeclared identifier ...\user.h(28) : error c2923: 'qlist' : 'read' not valid template type argument parameter 't'
read header:
#ifndef read_h #define read_h #include <qdatastream> #include "book.h" #include "date.h" class read { protected: //book book; date adddate; date readdate; bool stillreading; public: read(); ~read(); //read(book book, date adddate, date readdate, bool stillreading); //book getbook(); //void setbook(book book); date getadddate(); void setadddate(date adddate); date getreaddate(); void setreaddate(date readdate); bool isstillreading(); void setstillreading(bool stillreading); }; qdatastream &operator<<(qdatastream &out, const read &read); qdatastream &operator>>(qdatastream &in, read &read); #endif // read_h
book commented, because gives errors too...
...\user.h(13) : error c2065: 'read' : undeclared identifier
looks read not known in user.h. maybe date.h or book.h including user.h well? (circular references)
using prototype classes can prevent this.
Comments
Post a Comment