tli@sargas.usc.edu (Tony Li) (01/26/89)
Configuration: g++ 1.32, sun4-os4, libg++ 1.25 compiled with g++ 1.32 The following program generates garbage. It works fine on Sun 3's. ---------------------------------------------------------------------- #include <stream.h> class vector { protected: double *v; int sz; public: vector(int size) { sz = size; v = new double [sz]; } vector(const vector& vv) { sz = vv.size(); v = new double [sz]; for (int i = 0; i < sz; i ++) v[i] = vv[i]; } ~vector() { delete v; } double& operator[](int i) { return v[i]; } int& size(void) { return sz; } }; ostream& operator<<(ostream& s, const vector& v) { for (int i = 0; i < v.size(); i ++) s << v[i] << "\t"; return (s << "\n"); } main () { vector v(3); v[0] = 1.0; v[1] = 2.0; v[2] = 3.0; cout << v; } Tony Li - USC University Computing Services - Dain Bramaged. Uucp: oberon!tli Bitnet: tli@kylara, tli@ramoth Internet: tli@sargas.usc.edu
schmidt@siam.ics.uci.edu (Doug Schmidt) (01/26/89)
In article <14924@oberon.USC.EDU> tli@sargas.usc.edu (Tony Li) writes: ++ ++Configuration: g++ 1.32, sun4-os4, libg++ 1.25 compiled with g++ 1.32 ++ ++The following program generates garbage. It works fine on Sun 3's. ++---------------------------------------------------------------------- This program works fine on my sun 4 with libg++ 1.32. Perhaps you should get libg++ 1.32 from prep? It is quite nice. Doug -- schmidt@ics.uci.edu (ARPA) | Per me si va nella citta' dolente. office: (714) 856-4043 | Per me si va nell'eterno dolore. | Per me si va tra la perduta gente. | Lasciate ogni speranza o voi ch'entrate.