Read from cin or a file

Posted by m42a on Stack Overflow See other posts from Stack Overflow or by m42a
Published on 2010-03-09T06:35:36Z Indexed on 2010/03/09 6:51 UTC
Read the original article Hit count: 280

Filed under:
|
|

When I try to compile the code

istream in;
if (argc==1)
        in=cin;
else
{
        ifstream ifn(argv[1]);
        in=ifn;
}

gcc fails, complaining that operator= is private. Is there any way to set an istream to different values based on a condition?

© Stack Overflow or respective owner

Related posts about c++

Related posts about homework