jdg@sisd.kodak.com (Jeff Gortatowsky CUST) (07/22/90)
Here's a couple of possible TC++ 1.0 bugs. I'm still getting used
to C++ so maybe I'm wrong.
Try:
if (SomeCondition)
for (int i = 0; i < 100; i++) // <-- TC++ says this line in error
printf ("%d\n",i);
TC++ Tells me "Declaration not allowed here". I say, Why not?
However:
if (SomeCondition) { // < Note brace!
for (int i = 0; i < 100; i++) // <-- TC++ says this is A-OK
printf ("%d\n",i);
} // Note: Brace!
TC++ thinks this is dandy. "Me thinks it's a bug." The braces start
a new scope. That's why TC++ say everything is ok when braces are
present. But I thought you could declare variables just about anywhere.?
Now for a more complex problem. Starting with the mcircle example
program in the TC++ distribution I made a change or two. Lots
deleted for brevity!
// Classes: Location, Point, Circle, GMessage, and MCircle
// Class inheritance:
// Location->Point->Circle (Circle inherits Point which inherits Location)
// Location->GMessage (Notice Point is not inherited)
// (Circle and GMessage)->MCircle (Inherits Point from Circle, Yes?)
......
main(int argc, char **argv) //draws some circles with text
{
Point *pp; //Point pointer
MCircle Small(250, 100, 25, SANS_SERIF_FONT, "You"); //make an MCircle
pp = (Point *)&Small; // <- without explict cast, TC++ gives error
.......
}
Without the cast to Point pointer TC++ tells me it's an illegal assignment
even though Point is a base class of MCircle via Circle. Now GMessage
is derived from only Location. Is that the reason I must use a cast?
Because GMessage has no Point class? In multiple inheritance must
all base classes have a class of 'type' before you can use a base class
pointer? Something I'm missing?
BTW: Zortech 2.1 does not squawk about either example/bug.
--
Jeff Gortatowsky-Eastman Kodak Company .....uunet!atexnet!kodak!elmgate!jdg
(716)-726-0084
Eastman Kodak makes film not comments. Therefore these comments are mine
not theirs.