🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.tools.misc
Article #15

Re: [Q] Why doesn't this compile?

#15
From: Pete Becker
Date: Thu, 18 Apr 1996 17:40
29 lines
1646 bytes
In article <4l3hlj$6qt@mozo.cc.purdue.edu>, hillca@cs.purdue.edu says...
>
>In article <317523C0.5042@eps.agfa.be>, rorlic@eps.agfa.be says...
>>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.
>
>I think the error message is telling you exactly what is wrong.  You can't 
call 
>A::L::f because it is not a static function.  A static function is shared 
>between all instances of the class (it only has access to other static 
>members), while nonstatic functions all have have access to  the instance 
>specific data of the class. 
>
>A::L::f requires that f is a static function.  Which A object do you expect 
the 
>compiler to call f for?

There is no A object involved. B::L is derived from A::L, and the call 
A::L::f() is calling the f() that's defined in A::L. This call is legal. It's 
the compiler that's wrong.
Technical Details
Message-ID: <4l5uph$ng9@druid.borland.com>
Path: arc1-ca.pugleaf.net!druid.borland.com!usenet
References: <317523C0.5042@eps.agfa.be> <4l3hlj$6qt@mozo.cc.purdue.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!druid.borland.com!usenet
From: pete@borland.com (Pete Becker)
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: 18 Apr 1996 17:40:01 GMT
Organization: Borland International
Message-ID: <4l5uph$ng9@druid.borland.com>
References: <317523C0.5042@eps.agfa.be> <4l3hlj$6qt@mozo.cc.purdue.edu>
NNTP-Posting-Host: pbecker.borland.com
Mime-Version: 1.0
Content-Type: Text/Plain; charset=ISO-8859-1
X-Newsreader: WinVN 0.99.5