From -8367116216345827347 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,81811e4fa6bf189d,start X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 1995-02-20 17:55:34 PST Newsgroups: comp.std.c++ Path: nntp.gmd.de!stern.fokus.gmd.de!ceres.fokus.gmd.de!zib-berlin.de!news.mathworks.com!news.alpha.net!uwm.edu!math.ohio-state.edu!howland.reston.ans.net!news.sprintlink.net!EU.net!sun4nl!knowar!harmsen.knoware.nl!rharmsen From: rharmsen@knoware.nl (Ruud Harmsen) Subject: Template & inheritance: GURUS please help Sender: news@knoware.nl (News Account) Message-ID: Date: Tue, 21 Feb 1995 01:55:34 GMT Lines: 67 Nntp-Posting-Host: harmsen.knoware.nl Organization: none X-Newsreader: Trumpet for Windows [Version 1.0 Rev A] Keywords: Template Borland inheritance The following causes a syntax error under Borland C++ 3.1, and I just don't understand why: (see comments marked with @@@@@. The first compiler message, even if it were justified, still is an outright lie, I think. A compiler bug, or my ignorance? I hope the latter. ============================================================================ #include class B; template class A { public: someB *aB; }; class B { public: virtual int BMethod(int arg); void InternMethod(void); }; int B::BMethod(int arg) { printf("In BMethod, arg=%d\n", arg); return arg; } void B::InternMethod(void) { BMethod(13); } class myB: public B { public: int BMethod(int arg); }; class myA: public A { }; int main (int argc, char **argv) { class myA *aPA = new myA; // @@@@@ // Here BorlandC++ 3.1 says: // "InternMethod is not a member of MyB". // WHY NOT? It is, isn't it? aPA->aB->InternMethod(); delete aPA; class myB *adB = new myB; adB->InternMethod(); // @@@@@ but this is accepted ! return 0; } int myB::BMethod(int arg) { printf("In myB:BMethod, arg=%d\n", 2 * arg); return arg; }