I\'ve got a problem with this code:
#include
struct A
{
A(std::ifstream input)
{
//some actions
}
};
int main()
{
Two bugs:
ifstream
is not copyable (change the constructor parameter to a reference).A(input);
is equivalent to A input;
. Thus the compiler tries to call the default constructor. Wrap parens around it (A(input));
. Or just give it a name A a(input);
.Also, what's wrong with using a function for this? Only the class's constructor is used it seems, which you seem to abuse as a function returning void
.