| www.delorie.com/archives/browse.cgi | search |
| From: | "Brian MacBride" <macbride AT ix DOT netcom DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| 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> |
| Subject: | Re: Structs |
| Lines: | 60 |
| Organization: | Signal Computing Service Ltd. |
| MIME-Version: | 1.0 |
| 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" <ennui AT nettaxi DOT com> 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 <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 |