delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/03/30/17:46:52

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Recompiling old programs --> problems with fstream class
Date: Tue, 30 Mar 2004 17:37:08 -0500
Lines: 91
Message-ID: <c4csqo$2h0ge0$1@ID-227552.news.uni-berlin.de>
References: <b687bbff DOT 0403300531 DOT 2802145b AT posting DOT google DOT com>
NNTP-Posting-Host: user-2iveb6t.dialup.mindspring.com (165.247.44.221)
Mime-Version: 1.0
X-Trace: news.uni-berlin.de 1080686233 84951488 I 165.247.44.221 ([227552])
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113
X-Accept-Language: en-us, en, de, fr, ru, zh, ja
In-Reply-To: <b687bbff.0403300531.2802145b@posting.google.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Chris wrote:
> I cannot figure out why my old program no longer compiles under the
> current release of DJGPP (it worked with a REALLY old version).  As
> you can see,
> FSTREAM is include, but it says IFSTREAM is not declared in this
> scope?!  I
> do not understand this error.  Any help is greatly appreciated!
> 
> Code snippet from header file "matrix.h"

Corrected snippet:


#include <fstream>
using namespace std;
typedef double FLOAT_TYPE;

class Matrix
{
   private:
     char name[20];              // matrix name
     int rows;                   // matrix rows
     int columns;                // matrix columns
     FLOAT_TYPE *elem;           // pointer to matrix data
   public:
   // Constructors
       Matrix();                 // default constructor
       Matrix(float &);          // conversion constructor
       Matrix(Matrix &);         // copy constructor
       Matrix(char *);           // name-only constructor
       Matrix(int, int = 0);     // size-only constructor
       Matrix(char *, int, int = 0); // name & size constructor
   // Destructor
      ~Matrix();                 // destructor
   // Member Functions
     void SetName(char *);       // set matrix name
     void GetName(char *);       // get matrix name
     void SizeOf(void);          // display size of matrix
     int NRows(void);            // returns # of rows
     int NCols(void);            // returns # of columns
     void ReDim(int = 0, int = 0);   // set matrix dimensions
     void ReDim(Matrix &);       // set matrix dimensions
     void Randomize(int = 1, int = 0);   // randomize a matrix
     void Identity(int, int = 0);    // make Identity Matrix
     void Identity(Matrix &);    // make Identity Matrix
     int Diag(Matrix &);         // diagonalize a matrix
     void KeyLoad(void);         // load Matrix from Keyboard
     int LoadAscii(ifstream &);  // load Matrix from Ascii File
     int SaveAscii(ofstream &);  // save Matrix to Ascii File
     int Load(ifstream &);       // load Matrix from Matlab File
     int Save(ofstream &);       // save Matrix to Matlab File
     void ErrorHandler(int);     // matrix error handler
     FLOAT_TYPE Max(void);       // get max element
     FLOAT_TYPE Min(void);       // get min element
   // Overloaded Operators
       FLOAT_TYPE & operator() (int, int);   // overloaded () operator
       Matrix & operator() (int, int, int, int); // get a submatrix
       Matrix & operator+(Matrix &); // add matrices
       Matrix & operator-();     // negate matrix
       Matrix & operator-(Matrix &); // subtract matrices
       Matrix & operator*(Matrix &); // multiply matrices
       Matrix & operator=(Matrix &); // overloaded = operator
       Matrix & operator*=(Matrix &);    // element by element mult
       Matrix & operator!();     // invert matrix
       Matrix & operator~();     // transpose matrix
       Matrix & operator||(Matrix &);    // column augment 2 matrices
       Matrix & operator&&(Matrix &);    // row augment 2 matrices
     int operator==(Matrix &);   // compare 2 matrices
     operator  FLOAT_TYPE();     // Matrix -> FLOAT_TYPE
       Matrix & operator=(FLOAT_TYPE &); // FLOAT_TYPE -> Matrix
     friend Matrix & operator+(Matrix &, FLOAT_TYPE);    // add matrix &
                                                         // scalar
     friend Matrix & operator+(FLOAT_TYPE, Matrix &);    // add scalar &
                                                         // matrix
     friend Matrix & operator-(Matrix &, FLOAT_TYPE);    // subtract scalar
                                                         // from matrix
     friend Matrix & operator-(FLOAT_TYPE, Matrix &);    // subtract matrix
                                                         // from scalar
     friend Matrix & operator*(Matrix &, FLOAT_TYPE);    // multiply matrix
                                                         // & scalar
     friend Matrix & operator*(FLOAT_TYPE, Matrix &);    // multiply scalar
                                                         // & matrix
     friend ostream & operator<<(ostream &, Matrix &);   // overloaded <<
                                                         // operator
};






- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019