c++ - Too few template arguments error while trying to pass a list of pointers as a parameter? -
i've made "socialite" class, , separate "faction" class. 1 of arguments socialite object vector of pointers "factions". had used socialite class earlier without 'factionlist' parameter, , worked fine.
class socialite { public: socialite(); socialite(string lastname, string firstname, string userid, string picture, string website, string description, list<faction*> factionlist); //other methods void newsocialite(string lastname, string firstname, string userid, string picture, string website, string description, list<faction*> factionlist); void deletesocialite(string lastname, string firstname, string userid, string picture, string website, string description, list<faction*> factionlist); //other methods private: string lastname_; string firstname_; string userid_; string picture_; string website_; string description_; vector<socialite *> socialiteptr_; list<faction*> factionlist_; };
when included however, errors:
error c2976: 'std::list' : few template arguments
and
error c2065: 'faction' : undeclared identifier
on same line every time method/constructor contains factionlist. solutions looked involved code using templates, , i'm not using any, don't understand what's wrong.
extra info: vector of pointers stored in such way:
vector<faction *> factionptr_;
and make list in such way:
list<faction*> list_factions(factionptr_.begin(), factionptr_.end());
what doing wrong?
as @wojtek surowka said, can forward declare class faction
:
class faction; class socialite { ... }
or can include header file faction
declaration (if faction
declared in fraction.h
file):
#include "faction.h" class socialite { ... }
but in case faction.h
shouldn't include header socialite
class.
Comments
Post a Comment