Article View: comp.os.ms-windows.programmer.tools.misc
Article #16Re: [Q] Why doesn't this compile?
From: John Arisco
Date: Thu, 18 Apr 1996 18:15
Date: Thu, 18 Apr 1996 18:15
48 lines
2554 bytes
2554 bytes
I wrote: >> 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. Rob Stewart <stew@datalytics.com> wrote: > That's nonsensical. We're talking class declarations here. > B::L::f is a non-static member function of B::L, so it has a > this pointer. Although Rob is correct, what I meant to say was that there is no way to set the "this" pointer for B::L::f()'s call to A::L::f(). (In other words, when I said "its", I meant "A::L::f()'s", not "its own".) Unfortunately, I was still wrong. Chris Hill <hillca@cs.purdue.edu> wrote: > A::L::f requires that f is a static function. Which A object do > you expect the compiler to call f for? This is what I meant in my first post. However, it is wrong, because A::L is a base class of B::L, and the syntax for a method in a derived class to call a function in its base class is baseclassname::f(). When viewed in light of this, the call to A::L::f() definitely has a valid "this" pointer. Ranko Orlic <rorlic@eps.agfa.be> responded to Chris: > According to me you did not understand the error message > completely. The compiler incorrectly thinks that B::L::f is a > static member function. I don't think so. I think the compiler made the same error that I made. It didn't recognize that B::L::f() was calling a function in it's own base class, so it assumed that A::L::f() was a static function call, and it barfed because A::L::f() was not declared static. Ranko goes on to say: > The code IS perfectly legal. The compiler simply does not > work properly. Yes, I now agree with Rob and Ranko that this is a compiler bug and not a coding error. Sometimes you get the bear, sometimes the bear gets you. | 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:
<4l60lp$ot8@helium.einet.net>Path:
arc1-ca.pugleaf.net!helium.einet.net!usenetReferences:
<317523C0.5042@eps.agfa.be> <4l3cpv$l74@helium.einet.net> <3175EAD9.52CD@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: Thu, 18 Apr 1996 18:15:30 GMT Organization: TradeWave Corporation Message-ID: <4l60lp$ot8@helium.einet.net> References: <317523C0.5042@eps.agfa.be> <4l3cpv$l74@helium.einet.net> <3175EAD9.52CD@eps.agfa.be> NNTP-Posting-Host: platinum.einet.net X-Newsreader: Forte Free Agent 1.0.82