[comp.lang.c++] Zortech C++ bug

steve@hite386.UUCP (Usenet mail account) (03/05/89)

The Zortech C++ compiler v1.07c has a problem with the following code:

#include <stream.hpp>

class Node {
public:
   virtual void print(ostream& o) {
       o << "I am a Node\n";
   }
};

class IntNode : public Node {
public:
  int n;
  IntNode(int a = 0) : n(a) {}
  void print(ostream& o) {
       o << "I am an IntNode with value " << n << "\n";
  }
};


main()
{
  Node n;
  IntNode in(17);

  n.print(cout);
  in.print(cout);
  in.Node::print(cout);
}


The expected output is:                 The output of ZTC++ v1.07c is:

I am a Node                             I am a Node
I am an Intnode with value 17           I am an Intnode with value 17
I am a Node                             I am an Intnode with value 17


Comments?

With appreciation:

The above code example was taken from "The Journal of Object Oriented Pro-
gramming" Jan/Feb 1989 (C) 1989 by SIGS Publications, Inc.  Permission
was granted verbally to me by publisher Richard P. Friedman to post
this code from Andrew Koenig's C++ column entitled "How Virtual Functions
Work", pages 73-74, to Usenet. 


Steve Hite
Jacksonville, Florida
uunet!hite386!steve

johnm@trsvax.UUCP (03/06/89)

Ok, here's my problem with Zortech 1.07:

I'm trying to port Gorlen's classes to the PC and he has several declarations
like this in the file object.h...

overload MAX;
inline int MAX(int x, int y)	{ return...);
inline long MAX(long x, long y)	{ return...);
		.
		.
		.

Zortech balks at this and says that the second (and all subsequent occurances)
of MAX were previously declared as something else.  Since one of Mr. Bright's
primary critieria for the correctness of something is whether it goes through
the AT&T compiler, this would seem to be a bug.  After all, these were developed
on AT&T cfront 1.2.1 (it says so in the docs).

John Munsch