Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!uakari.primate.wisc.edu!ames!sun-barr!decwrl!shlump.nac.dec.com!ryn.esg.dec.com!ant.enet.dec.com From: avoncampe@ant.enet.dec.com (Alfred von Campe) Newsgroups: comp.sys.mac.programmer Subject: Re: Problem with Instance Variables in THINK C 4.0 Message-ID: <430@ryn.esg.dec.com> Date: 29 Aug 89 13:33:09 GMT Sender: guest@ryn.esg.dec.com Organization: Digital Equipment Corporation Lines: 129 Digital has been having some problems with its gateway (DECWRL) recently. I'm reposting this since I don't know if it made it out the first time. From: avoncampe@ant.enet.dec.com (Alfred von Campe) Subject: Problem with Instance Variables in THINK C 4.0 Date: 17 Aug 89 01:21:21 GMT Posted for a friend who currently doesn't have access to the net: -------------------------------------------------------------------------------- OK, I've run into a problem, no doubt easily solved, but it has eluded me for three days now. 1) I've declared a subclass of CScooterSamplePane (which is a subclass of CPanorama - See the Think C Class Library): struct CScooterSampleDial : CScooterSamplePane{ /* Class Declaration */ /* Instance Variables */ Point theStart, theEnd; /* Methods */ int Init( /* initialize the dial */ Point center, Point end, int length, int zeroOffset, double scale ); int Create( /* draw the pointer*/ int value ); int Update( /* update position*/ int delta ); } 2) I define the Methods: int CScooterSampleDial::Init( /* initialize pointer position values */ Point center, Point end, int length, int zeroOffset, double scale) { ... theStart.h = 50; theStart.v = 50; theEnd.h = 150; theEnd.v = 150; ... } int CScooterSampleDial::Create( /* create/display pointer at 1st position*/ int value) { ... MoveTo(theStart.h,theStart.v); LineTo(theEnd.h, theEnd.v); ... } int CScooterSampleDial::Update( /* update the pointer */ int value) { ... } 3) finally I Declare an instance and send some messages to the ...Dial object: ... CScooterSampleDial *theDial; /* declare an instance */ ... theDial = new(CScooterSampleDial); /* create an instance*/ theDial->Init(center, end, 15, 1, 1.0); /* send the configuration*/ theDial->Create(35); /* make the pointer*/ /* of course large chunks of irrelevant code have been omitted */ The Problem: When the Init object is finished, theStart and theEnd points are properly assigned as described in the Init method above. When I send to the Create method, theStart and theEnd are set to 0 for each member of those two Point structs. In the Think C Manual on Page 188 (Ch. 15 - Using Objects in Think C) it states that there is an implicit declaration register CLASS *this; and within a method definition one can omit the 'this->' from an instance variable. However, whether or not I use this->theStart.h or theStart.h in the Create method, I do not get the values established in the Init method. I've been through Chapters 14,15,&16 of the manual and have tried many different variations, to no effect as of yet. Any ideas ?? Scooter -------------------------------------------------------------------------------- Alfred +---------------------------------------------------------+--------------------+ | Easynet: ANT::AVONCAMPE |Work: (508) 480-5704| | uucp: {decvax,ucbvax,allegra}decwrl!dec-ant!avoncampe|Home: (508) 365-3982| |Internet: avoncampe@ant.enet.dec.com +--------------------+ +---------------------------------------------------------+ I'd rather be | | Thought for today: Why is common sense so uncommon? | FLYING | +---------------------------------------------------------+--------------------+ | Disclaimer: My employer doesn't even know I have opinions | +------------------------------------------------------------------------------+