From: "A.Appleyard" To: DJGPP AT SUN DOT SOE DOT CLARKSON DOT EDU Date: Fri, 24 Mar 1995 16:26:29 GMT Subject: Named return doesn't seem to work 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 #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.