The error you describe could not have come from the code you have provided; your class declaration is fine. It must have come from a different part of your code, in which you attempted to copy your XLSCreator
class, e.g. by invoking copy-assignment:
XLSCreator foo("filename");
XLSCreator bar = foo; //copies foo to create bar
The error arises when C++ attempts to generate a default copy-assignment operator for your class, which simply calls the copy-assignment operator of each member you've declared. std::ofstream
is non-copyable, as @chris said in the comments, so when the compiler attempts to call the copy assignment operator of filecontents
, it finds that it's not allowed to (operator=
is private within basic_ofstream
).
In order to fix this, you either need to ensure you never copy an XLSCreator
, or explicitly define a copy-assignment operator for XLSCreator
that somehow handles the filecontents
member without attempting to copy it.