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> |
Subject: | Re: Structs |
Lines: | 70 |
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: | <LCZ84.201$I51.5727@hnlnewsr1.hawaii.rr.com> |
Date: | Sat, 25 Dec 1999 06:37:31 GMT |
NNTP-Posting-Host: | 204.210.106.78 |
X-Complaints-To: | abuse AT rr DOT com |
X-Trace: | hnlnewsr1.hawaii.rr.com 946103851 204.210.106.78 (Fri, 24 Dec 1999 20:37:31 HST) |
NNTP-Posting-Date: | Fri, 24 Dec 1999 20:37:31 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:841d86$gg4 AT chronicle DOT concentric DOT net... > How can I link two different structs to the same function, without declaring > the function in both structs. > > for example > > int query_gold(); > > struct foo { > int la; > int pe; > } > > struct foo2 { > int la; > int pe; > } > > foo->query_gold(); > foo2->query_gold(); > > Thanks > > Requiem > iraemortis AT subdimension DOT com > > Consider... struct bar { int query_gold () { return 2; } }; struct foo : public bar { int la; int pe; }; struct foo2 : public bar { int la; int pe; }; #include <iostream.h> int main () { cout << foo ().query_gold () << endl; cout << foo2 ().query_gold () << endl; return 0; } /* Yields... 2 2 */ Is that what you wanted?? Regards Brian
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |