home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!ucbvax!hplabs!hplextra!rigel!hplabsz!chew
- From: chew@hplchew.hpl.hp.com (Chee Chew)
- Newsgroups: comp.lang.c++
- Subject: Re: HELP with overloading binary operator...
- Message-ID: <1992Jul28.191158.10829@hplabsz.hpl.hp.com>
- Date: 28 Jul 92 19:11:58 GMT
- References: <28JUL199210114546@ariel.lerc.nasa.gov>
- Sender: news@hplabsz.hpl.hp.com (News Subsystem (Rigel))
- Reply-To: web@athena.MIT.EDU
- Organization: Hewlett-Packard Laboratories
- Lines: 28
- To: smneyln@ariel.lerc.nasa.gov
- Nntp-Posting-Host: hplchew.hpl.hp.com
-
- In article <28JUL199210114546@ariel.lerc.nasa.gov>,
- smneyln@ariel.lerc.nasa.gov (Michael Neylon) writes:
- |>I have the following class...
- |>
- |>classs ARRAYBASE {
- |>private: float matrix[MAXSIZE][MAXSIZE];
- |>public: int xsize, ysize;
- |> ARRAYBASE(int x, int y) {xsize=x+1;ysize=y+!;};
- |>// put + get handlers
- |>// overloaded operator= which is fine
- |>// Inverse() function, taken from _Num. Rec. in C_
- |> ARRAYBASE ARRAYBASE::operator*(ARRAYBASE array1, ARRAYBASE array2)
- |> {
- |> //fill the array using matrix multiplication
- |> //fill in matrix[][] and xsize, and ysize vars
- |> return *this;
- |> };
- |>};
- |>
-
- since your * is a non-static member function, it takes one argument
- (your array2). Array1 will be
- the "this".
-
- a function overloading * will take two arguments if it is a static
- member, or a non member function.
-
- -Chee
-