[comp.sys.mac.programmer] OOPS/TCL question

rob@cs.mu.oz.au (Robert Wallen) (10/24/89)

Well, having just got my copy of Think C 4.0 torn open (you know, in christmas
present frenzy mode) and all installed, I have a couple of sorta dumb questions
to ask the world. This is the first ...

Am I missing something or is the 'A::' not necessary in the call to x() because
B has inherited it and thus 'this->x()' will do?  Therefore 'x()' will do too.

struct A : direct { void x(void); };
struct B : A { void y(void); };
...
B::y(void)
{
	A::x();
}

I know its not necessary because I tried compiling it and it works fine.
Why does the Think Class Library seem to specify these things when it doesnt
need to??

fjlim@garnet.berkeley.edu (10/25/89)

In article <2849@murtoa.cs.mu.oz.au> rob@cs.mu.oz.au (Robert Wallen) writes:
>Am I missing something or is the 'A::' not necessary in the call to x() because
>B has inherited it and thus 'this->x()' will do?  Therefore 'x()' will do too.
>
>struct A : direct { void x(void); };
>struct B : A { void y(void); };
>...
>B::y(void)
>{
>	A::x();
>}
>
>I know its not necessary because I tried compiling it and it works fine.
>Why does the Think Class Library seem to specify these things when it doesnt
>need to??

I believe that the only places where such unnecessary specifications occur
in the TCL are in initialization methods. For example,
	CBureaucrat::IBureaucrat(aSupervisor);
appears in the CDirector::IDirector() method.

CDirector is a subclass of CBureaucrat, so the IBureaucrat() method is
inherited and it is unnecessary to explicitly specify the class name.
I included the specification as a self-documenting feature which reinforces
the concept that the superclass initialization method is being called.
It's a matter of personal style, similar to the choice of whether or not
to prefix instance variables and methods with "this->".

Greg Dow, author of the TCL