🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#8
From: Chris Hill
Date: Wed, 17 Apr 1996 19:43
25 lines
1367 bytes
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?

-- 
Chris Hill
hillca@cs.purdue.edu
Technical Details
Message-ID: <4l3hlj$6qt@mozo.cc.purdue.edu>
Path: arc1-ca.pugleaf.net!mozo.cc.purdue.edu!news
References: <317523C0.5042@eps.agfa.be>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mozo.cc.purdue.edu!news
From: hillca@cs.purdue.edu (Chris Hill)
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: 17 Apr 1996 19:43:47 GMT
Organization: Purdue University
Message-ID: <4l3hlj$6qt@mozo.cc.purdue.edu>
References: <317523C0.5042@eps.agfa.be>
NNTP-Posting-Host: lab40.cs.purdue.edu
Mime-Version: 1.0
Content-Type: Text/Plain; charset=US-ASCII
X-Newsreader: WinVN 0.99.7