Article View: comp.os.ms-windows.programmer.tools.misc
Article #6Re: [Q] Why doesn't this compile?
From: John Arisco
Date: Wed, 17 Apr 1996 18:24
Date: Wed, 17 Apr 1996 18:24
53 lines
1738 bytes
1738 bytes
Ranko Orlic <rorlic@eps.agfa.be> wrote:
>Using MSVC 4.0 compiler I get the following:
>File test.cpp: ---------------------------------
>class A {
>public:
> class L {
> public:
> L() {}
> virtual void f() {
> int dummy = 0;
> }
> };
> A();
>};
>class B : public A {
> class L : public A::L {
> public:
> L() {}
> virtual void f() {
> A::L::f();
> }
> };
> B();
>};
>Compilation result: ----------------------------
>test.cpp(18) : error C2352: 'A::L::f' : illegal call of
>nonstatic member function
>Error executing cl.exe.
>test.obj - 1 error(s), 1 warning(s)
>------------------------------------------------
>Anybody knows what's wrong with it?
>Thanks,
>-- Ranko.
You cannot call a non-static member function without specifying
an object. The way you've written this, there is no way for B::L::f()
to set its "this" pointer. Of course, if this is really what you want
to do, the declaration of B::L::f() is unnecessary, since B::L
inherits the A::L::f() virtual method from its base class.
| John Arisco <arisco@tradewave.com>
| TradeWave Corp, 3636 Executive Center Dr, #100, Austin, TX 78731
| Voice: (512) 433-5313 Main: 433-5300 Fax: 433-5303
Technical Details
Message-ID:
<4l3cpv$l74@helium.einet.net>Path:
arc1-ca.pugleaf.net!helium.einet.net!usenetReferences:
<317523C0.5042@eps.agfa.be>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!helium.einet.net!usenet From: arisco@tradewave.com (John Arisco) Newsgroups: comp.os.ms-windows.programmer.tools.misc,comp.os.ms-windows.programmer.win32,comp.os.ms-windows.programmer.misc,comp.lang.c++ Subject: Re: [Q] Why doesn't this compile? Date: Wed, 17 Apr 1996 18:24:07 GMT Organization: TradeWave Corporation Message-ID: <4l3cpv$l74@helium.einet.net> References: <317523C0.5042@eps.agfa.be> NNTP-Posting-Host: platinum.einet.net X-Newsreader: Forte Free Agent 1.0.82