From: "Requiem" Newsgroups: comp.os.msdos.djgpp Subject: Re: Structs Date: 25 Dec 1999 11:25:17 EST Organization: Concentric Internet Services Lines: 143 Message-ID: <842r5d$4ec@journal.concentric.net> References: <841d86$gg4 AT chronicle DOT concentric DOT net> NNTP-Posting-Host: ts004d33.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 I don't think so...I don't want query gold to return a static number, but a variable attached to the struct. foo.query_gold(); returns la; Requiem ennui AT nettaxi DOT com > > 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 > > int main () { > cout << foo ().query_gold () << endl; > cout << foo2 ().query_gold () << endl; > return 0; > } > > /* > Yields... > 2 > 2 > */ > > Is that what you wanted?? > > Regards > > Brian > > > > 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 > > int main () { > cout << foo ().query_gold () << endl; > cout << foo2 ().query_gold () << endl; > return 0; > } > > /* > Yields... > 2 > 2 > */ > > Is that what you wanted?? > > Regards > > Brian > >