www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/02/06/17:15:34

From: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
To: DJGPP AT SUN DOT SOE DOT CLARKSON DOT EDU
Date: Mon, 6 Feb 1995 14:33:00 GMT
Subject: Funny error in class

This short test program:-
  .......................
#include <sys/farptr.h>
/*-----*/
class scrlword; class scraddr;
class scraddr{public: short i;
    scrlword operator*();      /* 1 */
    inline scraddr operator=(scraddr z){i=z.i; return *this;};
};
class scrlword{public: short i;
inline short(){return _farnspeekw(0xb8000+i);};
inline scrlword(short&s){_farnspokew(0xb8000+i,s);};
};
inline scrlword scraddr::operator*(){scrlword s; s.i=i; return s;};  /* 2 */
  .........................
got the following errors. But definition line /* 2 */ seems to me to be a
valid match for declaration line /* 1 */. My function `operator*()' is clearly
defined as a member of class scraddr; why on earth is the compiler looking in
class scrlword for its matching declaration!? :-
  .........................
C:\AM>gcc t$1.cc
C:\AM>c:\djgpp\bin\gcc t$1.cc
t$1.cc: In method `class scrlword scraddr::operator (unary *)()':
t$1.cc:12: no matching function for call to `scrlword::scrlword ()'
t$1.cc:0: candidates are: scrlword::scrlword(const scrlword &)
t$1.cc:10:                 scrlword::scrlword(short int &)
t$1.cc:12: in base initialization for class `scrlword'














- Raw text -


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