S
Stefan Strasser
JH said:void foo(std::istream &in)
{
int i, j;
in >> i >> j;
} // foo
int main()
{
foo(std::istringstream("1 1"));
return 0;
} // main
g++ gives the following complaint when I attempt to compile this code:
error: invalid initialization of non-const reference of type
'std::istream &' from a temporary of type 'std::istringstream'
I was under the impression that my code above was standard-conforming.
Am I wrong on this point?
calling a constructor creates a temporary. temporaries are const. your
parameter of "foo" is not. you could pass it by value to make it work e.g.
since vs .net seems to be very standard conforming I guess this is some
sort of extension which can be turned off.