Reputation: 1578
I have following structure,
struct option
{
std::fstream fpointer;
char* clifn;
};
I want to pass this structure as argument to another function (other way is to pass individual element and fpointer as reference), passing it to function throws a compiler error
error C2248: 'std::basic_fstream<_Elem,_Traits>::basic_fstream' : cannot access private member declared in class 'std::basic_fstream<_Elem,_Traits>'
is there any way to pass std::fstream object of struct member to function.
Upvotes: 0
Views: 347
Reputation: 121971
Streams are not copyable so struct option
is therefore not copyable because it has a non-copyable member (fpointer
). Pass struct option
by reference to avoid the copy:
void some_function(option& a_option)
{
}
Upvotes: 6