From: jakarppi AT tuomi DOT oulu DOT fi (Jari Karppinen) Newsgroups: comp.os.msdos.djgpp Subject: a trouble with c++ code Date: 1 Feb 1999 13:40:25 GMT Organization: University of Oulu, Mathematics Department Lines: 169 Message-ID: <794as9$cpo$1@ousrvr3.oulu.fi> NNTP-Posting-Host: tuomi.oulu.fi X-Trace: ousrvr3.oulu.fi 917876425 13112 130.231.241.29 (1 Feb 1999 13:40:25 GMT) X-Complaints-To: news AT news DOT oulu DOT fi NNTP-Posting-Date: 1 Feb 1999 13:40:25 GMT X-Newsreader: TIN [UNIX 1.3 unoff BETA release 960807] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I wrote a simple program which implements classes for matrices and vectors. When I compile the program under Unix, it runs without trouble. However, a version compiled with djgpp doesn't work right. The program is supposed to read data for a matrix and a vector and then print their product (that is, b=m*a, where m is the matrix and a,b are vectors). If I feed it for example m=1 0 0 1 (2x2 identity matrix) and a=10 10 it prints 10 10 under Unix... but a djgpp compiled exe prints 0 1.4013e-44. Any ideas why it doesn't work? The source is below: -- #include class vector; class matrix { int rows,cols; float **elems; public: matrix(); matrix(int,int); ~matrix(); matrix operator=(const matrix&); friend vector operator*(const matrix&,const vector&); void set(int,int,float); matrix& input(); void print(); }; matrix::matrix() { rows=1; cols=1; elems=new float*[rows]; elems[0]=new float[1]; elems[0][0]=0; } matrix::matrix(int m,int n) { rows=m; cols=n; elems=new float*[rows]; for (int i=0;i> rows >> cols; elems=new float*[rows]; for (i=0;i> elems[i][j]; return *this; } void matrix::print() { cout << "\n"; for (int i=0;i> cols; elems=new float[cols]; cout << "\nFeed me Seymour... I need data for a " << cols << "-vector.\n"; for (int j=0;j> elems[j]; return *this; } void vector::print() { cout << "\n"; for (int i=0;i