From: Bill Currie Newsgroups: comp.os.msdos.djgpp Subject: Re: C++ and globals ?? Date: Tue, 02 Dec 1997 11:03:21 +1300 Organization: Telecommunication Systems Support Centre Lines: 40 Message-ID: <34833429.3D1D@tssc.co.nz> References: <34832B11 DOT 7408 AT netunlimited DOT net> NNTP-Posting-Host: node106.tssc.co.nz Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk gilley wrote: > //globals > FONT *myfont; > FONT *systemfont; > > class MyClass > { > Font *myfont; > void afunction(void); > > }; > void MyClass::afunction(void) > { > systemfont=myfont; > }; > > OK now the question is.. in afunction() > is the systemfont now poining to MyClass.myfont > or is it pointing to the global myfont? > > How do I distinguish the two? Should I say > This.myfont to be sure I am getting the myfont > var in the class? > > Thanks all, > I know its a dumb question. :) Not dumb, just... dunno. Wrong group, anyway. Anyway, systemfont points to MyClass::myfont. Use scoping rules, member variables are in the scope of member functions. To get at the global myfont from a MyClass member function, use `::'. ie void MyClass::afunction(void) { systemfont=::myfont; }; Bill -- Leave others their otherness