www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/08/13:16:07

From: gsm77 AT aol DOT com (GSM77)
Newsgroups: comp.os.msdos.djgpp
Subject: Incomprehensible Warning (He's back ...)
Date: 8 Jun 1998 16:02:38 GMT
Lines: 50
Message-ID: <1998060816023800.MAA04648@ladder03.news.aol.com>
NNTP-Posting-Host: ladder03.news.aol.com
References: <1998060810415801 DOT GAA15169 AT ladder03 DOT news DOT aol DOT com>
Organization: AOL, http://www.aol.fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019