Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!mailrus!umich!umeecs!yhe From: yhe@zip.eecs.umich.edu (Youda He) Newsgroups: comp.lang.c++ Subject: C++ questions on Zortech and g++ Message-ID: <1382@zipeecs.umich.edu> Date: 5 Feb 90 22:05:38 GMT References: <2815@draken.nada.kth.se> <636@tci.bell-atl.com> <7722@chaph.usc.edu> <645@tci.bell-atl.com> <133@dumbcat.UUCP> <3062@pur-phy> <3575@odin.SGI.COM> Reply-To: yhe@eecs.umich.edu (Youda He) Organization: University of Michigan EECS Dept., Ann Arbor, MI Lines: 106 // Here is a test program, I compiled it on sun4 use g++ 1.36.4 // on PC use zortech 2.01 (Still haven't get update). // On PC Zortech report "Heap is corrupted" // g++ will not compile for Vector class member access BaseVector // protected member function/variable. // after I made entire BaseVector public, it compiled ok, and the output // list at the end, program compiled by both compiler give similar result, // Both looks not right! // so please some one has other compiler (AT&T 2.0) give it a try? #ifdef __ZTC__ #include #else #include #endif class BaseVector { public: // inorder to compile on g++, declear everybody public; // to compile on PC remove these two lines. //protected: // original protected: double *vector_ptr; int len; BaseVector(int len=10); //public: // public: ~BaseVector(); double & operator[](const int index); friend ostream& operator << (ostream&, BaseVector&); }; class Vector : public BaseVector { public: Vector(int len=10):(len) {} ~Vector() {} BaseVector operator + (const Vector&); }; BaseVector::BaseVector(int sz) { vector_ptr = new double[len=sz]; cout << "Base CTOR called " << (unsigned long) vector_ptr << "\n"; } BaseVector::~BaseVector() { cout << "Base DTOR called " << (unsigned long) vector_ptr << "\n"; delete vector_ptr; } double & BaseVector::operator[](const int i) { return *(vector_ptr+i); } BaseVector Vector::operator+(const Vector & x) { BaseVector tmp(len); for(int i=0; i