まあ、一般的に、目標は、関数内で、私のクラスのオブジェクト、またはcout | cin。istream、ostreamからクラスを正しく継承するには?
MyStream mout = MyStream();
MyStream min = MyStream();
...
static int UShowTFileList(ostream& out, istream& in);
...
UShowTFileList(cout, cin);
UShowTFileList(mout,min);
明らかな解決策は機能しません。コンストラクタはありません。
class MyStream : public ostream, public istream {...}
...
MyStream mout = MyStream();
MyStream min = MyStream();
...
-->
Error (active) E1790 the default constructor of "MyStream" cannot be referenced -- it is a deleted function
まあ、すべての課題です。
mout << "Hello, world!" << "\n";
->
Error C2280 'MyStream::MyStream(const MyStream &)': attempting to reference a deleted function
通常、istream、ostreamをどのように正しく継承しますか? MyStream.h
std :: ostreamから継承する必要はありません。あなたは通常、関数std :: ostream&operator <<(std :: ostream&os、MyType const & m); ' – Galik
)をオーバーロードします。このポストはこれに使うことができます:https://stackoverflow.com/questions/37720431/what-is- -cc-equivalence-of-java -ioio-serializable/37721075#37721075 – Galik
@ Galik通常のオーバーロードが機能するので、コンストラクタを使用して、 "mout"、 "min"、および標準スレッドで動作させることができます。 – Evgen8