Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!lll-winken!cert!netnews.upenn.edu!tandem.physics.upenn.edu!claytor From: claytor@tandem.physics.upenn.edu (Nelson Claytor) Newsgroups: comp.sys.mac.programmer Subject: Re: Casting in Think C Message-ID: <34174@netnews.upenn.edu> Date: 6 Dec 90 15:12:47 GMT Sender: news@netnews.upenn.edu Organization: University of Pennsylvania Physics Dept. Lines: 28 References:<6167@munnari.oz.au> <3028@skye.cs.ed.ac.uk> <6194@munnari.oz.au> In article <6194@munnari.oz.au> caw@munnari.oz.au (Chris Wright) writes: > In article <3028@skye.cs.ed.ac.uk>, nick@cs.edinburgh.ac.uk (Nick Rothwell) writes: > > In article <6167@munnari.oz.au>, caw@munnari.oz.au (Chris Wright) writes: > > > Why do you have to cast gApplication in ThinkC e.g.: > > > extern CApplication *gApplication; > > > > gApplication is still a CApplication, and hence doesn't have an IEditApp() > > method unless you cast it. > > If my memory serves me correctly, gApplication is now a > CEditApp. This can be checked with the member function. > So it SHOULD have an IEditApp(). And the compiler > shouldn't complain. At runtime, yes, gApplication is a CEditApp, and therefore it does have the IEditApp() method. However, at compile time, all the compiler knows is that you declared it as a CApplication. Therefore, *as far as the compiler is concerned*, there is no IEditApp. Nelson Nelson Claytor claytor@tandem.physics.upenn.edu