Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
クラスのコンストラクターがあります: class(ofstream & o). クラス変数を設定したいofstream out。問題はout = o、エラーが発生せずに使用できないことです。
class(ofstream & o)
ofstream out
out = o
あなたがすることは次のようなものです:
class MyClass { ofstream& out; MyClass(ofstream& o) : out(o) {} ... };
outこれは機能し、内部的には通常どおり使用できます。
out
あなたの質問では、あなたは言うofstream out. ファイルストリームを「コピー」することはできないため、参照でout = oない限り言うことはできませんout。