delorie.com/archives/browse.cgi | search |
From: | "Requiem" <ennui AT nettaxi DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Structs |
Date: | 25 Dec 1999 15:01:28 EST |
Organization: | Concentric Internet Services |
Lines: | 59 |
Message-ID: | <8437qo$bia@journal.concentric.net> |
References: | <841d86$gg4 AT chronicle DOT concentric DOT net> <LCZ84.201$I51 DOT 5727 AT hnlnewsr1 DOT hawaii DOT rr DOT com> <842r5d$4ec AT journal DOT concentric DOT net> <_T894.2517$PC DOT 23927 AT hnlnewsr2 DOT hawaii DOT rr DOT com> |
NNTP-Posting-Host: | ts029d38.chi-il.concentric.net |
X-Priority: | 3 |
X-MSMail-Priority: | Normal |
X-Newsreader: | Microsoft Outlook Express 5.00.2615.200 |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2615.200 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Looks good, can I do this in C? Requiem > > 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 <class T> > 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 <iostream.h> > > int main () { > cout << query_gold (foo ()) << endl; > cout << query_gold (foo2 ()) << endl; > return 0; > } > > /* > Yields... > 2 > 3 > */ > > Regards > > Brian > >
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |