0

istream in パラメーターを持つコンストラクターを持つ派生クラスに問題があります。

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;  
}

わかりましたので、ここでの問題は簡単です。istreamコンパイラでは、派生クラス Livre 用に別のコンストラクタを作成できません。私の Reference クラスは抽象クラスであり、コンストラクター Livre で Reference のストリームを使用してコンストラクターを呼び出して情報を完成させる必要があります。私が持っている他のオプションは、次のように上書きすることです

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

私のLivre.cppに。誰かがそれを行うためのより良い方法を私に説明できれば、私は本当に感謝しています. たくさんのコードがあることはわかっていますが、問題を説明するのは簡単ではありません。みんなありがとう。

4

1 に答える 1