L
loufoque
Noah said:(argc > 2
? ofstream(argv[2], ios:ut | ios::binary)
: cout)
This is not equivalent to
ofstream out(argv[2], ios:ut | ios::binary);
(argc > 2 ? out : cout)
Noah said:(argc > 2
? ofstream(argv[2], ios:ut | ios::binary)
: cout)
Herb said:I'm not sure what it says in your printing, but IIRC in should have type
ifstream and out should have type ofstream. Then the code compiles fine
under most modern compilers (incl. EDG and gcc 3.x and 4.x).
It also worked fine under VC++ 6 (current when the book was published),
but oddly it apparently doesn't under VC++ 7.1 (2003) and 8.0 (2005). Hmm.
I'll look into it. In the meantime, a workaround would be to not use the
cuteness of the ternary operator, and work with a pointer instead:
ifstream in;
basic_istream<char>* i = &cin;
ofstream out;
basic_ostream<char>* o = &cout;
if( argc > 1 ) {
in.open ( argv[1], ios::in | ios::binary );
i = ∈
}
if( argc > 2 ) {
out.open( argv[2], ios:ut | ios::binary );
o = &out;
}
Process( *i, *o );
Alf said:* Noah Roberts:
No, I don't have that book.
Next, the roles of E1 and E2 need to be switched and this new situation
analysed, but there's no way to convert std:stream down to std:fstream.
CC: Herb Sutter.
I don't think I will ever understand why some people choose to play
this kind of game. You can claim you don't know but we both know you
do, and did all along, but for some reason want to pretend you don't
and so we have to take 50 steps back into pedant mode and pretend to
bring you up to speed. There's no reason for it really; it serves no
other purpose than to slow down discussion and I honestly don't get it.
My guess is that it is some sort of power play mechanism but I don't
really understand why you would feel the need for that with me. I find
people that choose this method of communication very frustrating to
work with.
Thank you for your eventual answer.
When you figure it out I would very much like to know and
**you can post to my personal email**, if you wish.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.