1
継承されたクラスの演算子を< <にオーバーロードしましたが、正常に動作していますが、演算子>>をオーバーロードしようとすると、多くのエラーが発生します。 私の間違いは何ですか?Overload >> in inherited class C++
class Base{
private:
virtual std::ostream& print(std::ostream&) const = 0;
virtual std::istream& read(std::istream&);
protected:
//atributes
public:
//other functions
friend std::ostream& operator << (std::ostream& os, const Base& b) {
return b.print(os);
}
friend std::istream& operator >> (std::istream& is, Base& bb) {
return bb.read(is);
}
};
class Inherited: public Base{
private:
//atributes
std::ostream& print(std::ostream& os) const {
//things I want to print
}
std::istream& read(std::istream& is){
//things I want to read
return is;
}
public:
//other functions
};
istreamをvirtual pure(virtual ... const = 0;)として定義しても動作しません。
[MCVE](https://stackoverflow.com/help/mcve)を提供してください。このMCVEで、コンパイラからエラーのテキストと正確なテキストをコンパイルしようとします。 – yeputons