home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!umn.edu!csus.edu!borland.com!pete
- From: pete@borland.com (Pete Becker)
- Subject: Re: Matrix Addition Was Re: Complex Addition.
- Message-ID: <1992Dec17.184348.217@borland.com>
- Originator: pete@genghis.borland.com
- Keywords: operator, memory leak
- Sender: news@borland.com (News Admin)
- Organization: Borland International
- References: <1992Dec11.170849.18525@rs6000.bham.ac.uk> <1992Dec11.232954.7071@borland.com> <36223@sophia.inria.fr>
- Date: Thu, 17 Dec 1992 18:43:48 GMT
- Lines: 26
-
- In article <36223@sophia.inria.fr> gchow@hawai.inria.fr (Gloria Chow) writes:
- >
- >How about if the structure is a bit more complex, especially one with
- >dynamically allocated memory. I tried the following (I appologize if it's
- >syntactically incorrect, I no longer have the version which I actually tried.
- >This one is just from memory):
- >
- >class MATRIX
- >{
- >protected:
- > double **entry;
- > int nrows, ncols;
- >public:
- > MATRIX( int num_rows, int num_cols );
- > MATRIX& operator=( const MATRIX& equivalent );
- > MATRIX& operator+( const MATRIX& addend );
- >};
- >
-
- Add a copy constructor. If you don't supply one, the compiler will
- provide one for you, and it often won't do what you want it to do. In
- general, there are three member functions that should probably all be present
- if any one of them is: assignment operator, copy constructor, and destructor.
- -- Pete
-
-
-