From: "Brian MacBride" Newsgroups: comp.os.msdos.djgpp References: <841d86$gg4 AT chronicle DOT concentric DOT net> <842r5d$4ec AT journal DOT concentric DOT net> Subject: Re: Structs Lines: 60 Organization: Signal Computing Service Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Message-ID: <_T894.2517$PC.23927@hnlnewsr2.hawaii.rr.com> Date: Sat, 25 Dec 1999 19:26:50 GMT NNTP-Posting-Host: 204.210.106.78 X-Complaints-To: abuse AT rr DOT com X-Trace: hnlnewsr2.hawaii.rr.com 946150010 204.210.106.78 (Sat, 25 Dec 1999 09:26:50 HST) NNTP-Posting-Date: Sat, 25 Dec 1999 09:26:50 HST To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Requiem" wrote in message news:842r5d$4ec AT journal DOT concentric DOT net... > I don't think so... It is a little tougher when neither of us can define the problem. I don't want query gold to return a static number, but a > variable attached to the struct. > > foo.query_gold(); returns la; > Consider... // // $Log: FooFoo.cpp,v $ // Revision 1.2 1999-12-25 09:26:23-10 brian_macbride // 2nd try... // // Revision 1.1 1999-12-25 09:19:52-10 brian_macbride // 1st try... // template int query_gold (const T &f) { return f.la; }; struct foo { int la; int pe; foo () : la (2) {} }; struct foo2 { int la; int pe; foo2 () : la (3) {} }; #include int main () { cout << query_gold (foo ()) << endl; cout << query_gold (foo2 ()) << endl; return 0; } /* Yields... 2 3 */ Regards Brian