Mail Archives: djgpp/1998/06/08/13:16:07
Ok, more of you don't know the "static_cast"
But the code which follow produce the same warning,
that I don't understand (may be 'cause I'm french ... ).
the code :
==========================
#include <fstream.h>
class X
{
int data;
public:
friend istream & operator >> (istream & , X & );
};
class Y
: public X
{
int OtherData;
public:
friend istream & operator >> (istream & , Y & );
};
istream & operator >> (istream & os, X & me)
{
return os >> me.data;
}
istream & operator >> (istream & os, Y & me)
{
os >> (X)me; /* This line produce the warning */
os >> me.OtherData;
}
==========================
produce the warning :
===================================================
In function `class istream & operator >>(class istream &, class Y &)':
Warning: initialization of non-const reference `class X &' from rvalue `X'
Warning: in passing argument 2 of `operator >>(istream &, X &)'
===================================================
I know that it's only a warning, but i learnt they often hide huge fooleries.
Does anyone have any idea ?, or explanation for a poor frenchy ... :-(
Kamy.
- Raw text -