C++, Constructor with istream on a derivate class -


i have problem derived class have constructor istream in parameter.

reference.cpp_

.... reference::reference(istream& p_is) {...} .... 

livre.h_

class livre : public reference     {      private:     void verifieinvariant() const;     std::string m_editeur;     std::string m_isbn;      public:      livre(         const std::string& p_cote,         const std::string& p_theme,         const std::string& p_titre,         const std::string& p_auteurs,         int p_anneeedition,         const util::date& p_dateacquisition,         const std::string& p_editeur,         const std::string& p_isbn);      livre(std::istream& p_is); ... 

livre.cpp

.... livre::livre(std::istream& p_is) {      reference(std::istream& p_is);     string editeur ="";      string isbn = "";     string buffer = "";     getline(p_is, buffer);     getline(p_is, editeur);     getline(p_is, isbn);      m_editeur = editeur;     m_isbn = isbn;   } 

ok problem here it's simple. compiler doesn't let me create constructor istream derived class livre. reference class abstract 1 , need call constructor stream of reference in constructor livre complete information. other option have write on like

reference::reference(std::istream& p_is) {...} 

into livre.cpp. if can explain me better way appreciate. know have lot of code it's not easy explain problem. guys.

i'm not sure if it's problem, believe correct way rewrite

livre::livre(std::istream& p_is) {     reference(std::istream& p_is);     /* ... */ } 

as

livre::livre(std::istream& p_is) : reference(p_is); {     /* ... */ } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -