Date: Mon, 6 Feb 95 17:54:10 -0500 From: dj AT stealth DOT ctron DOT com (DJ Delorie) To: A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk Cc: DJGPP AT sun DOT soe DOT clarkson DOT edu Subject: Re: Funny error in class First off, I don't recommend using the farns* functions inside other functions. It's not safe. You don't know what someone else might have done with the segment registers between calls. > #include > > class scrlword; > class scraddr; > > class scraddr { > public: > short i; > scrlword operator*(); > 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) { /* 1 */ > _farnspokew(0xb8000+i,s); > }; > }; > > inline scrlword scraddr::operator*() > { > scrlword s; /* 2 */ > s.i=i; > return s; > }; In line /* 1 */ above (code reformatted for readability), you declare that the class scrlword has a single constructor that takes an argument. In line /* 2 */ above, you create an object of that type, which implies that you call the constructor, but you do not provide arguments to match the one constructor you have. The other constructor gcc lists is the default copy constructor, which you don't have either. You need to either explicitely provide an argument-less constructor, or pass a short when you declare the object.