Reputation: 1417
I have a constructor for my class: class(ofstream & o)
. I want to set my class variable ofstream out
. The problem is I can't use out = o
without getting an error.
Upvotes: 0
Views: 139
Reputation: 29019
What you'd do is something like:
class MyClass
{
ofstream& out;
MyClass(ofstream& o) : out(o)
{}
...
};
This will work, and internally you can use out
as usual.
In your question, you say ofstream out
. You cannot "copy" file streams, so you cannot say out = o
unless out
is a reference.
Upvotes: 2