Mail Archives: djgpp/1995/03/24/13:55:46
File C:\DJGPP\DOCS\GCC\EXTEND.TEX says (somewhat de-TeXified):-
> @section Named Return Values in C++
> ...
> `type' `functionname' ( `args' ) return `resultname'; { ... `body' ... }
> You can use this feature to avoid an extra constructor call when a
> function result has a class type. For example, consider a function m, ...
> whose result is of class X:-
> X m () { X b; b.a = 23; return b; }
> ... [can otherwise be written as:-]
> X m () return r; { r.a = 23; }
So I tried it in the 14th line of this:-
#include <go32.h>
#define uns unsigned
class c_byte_addr;
/*-----*/
class c_byte {public: uns int addr;
inline c_byte operator&(c_byte_addr&x);
inline uns char operator=(char c){dosmemput(&c,1,addr); return c;};
inline char(){char c; dosmemget(addr,1,&c); return c;};};
/*-----*/
class c_byte_addr {public: uns int addr;
inline c_byte_addr(uns int Addr){addr=Addr;};
inline c_byte_addr(uns short Seg,uns short Offset){addr=Seg*16+Offset;};
//inline c_byte operator*(){return *(c_byte*)(this);};
inline c_byte operator*() return r; {r.addr=addr;};};
/*-----*/
inline c_byte c_byte::operator&(c_byte_addr&x){addr=x.addr;};
but djgpp refused it:-
C:\WORK>c:\djgpp\bin\gcc dos.cc
dos.cc:14: parse error before `return'
dos.cc:14: parse error before `}'
Removing the `inline' on that line made no difference.
- Raw text -