home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11688 < prev    next >
Encoding:
Internet Message Format  |  1992-07-28  |  1.3 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!ucbvax!hplabs!hplextra!rigel!hplabsz!chew
  2. From: chew@hplchew.hpl.hp.com (Chee Chew)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: HELP with overloading binary operator...
  5. Message-ID: <1992Jul28.191158.10829@hplabsz.hpl.hp.com>
  6. Date: 28 Jul 92 19:11:58 GMT
  7. References: <28JUL199210114546@ariel.lerc.nasa.gov>
  8. Sender: news@hplabsz.hpl.hp.com (News Subsystem (Rigel))
  9. Reply-To: web@athena.MIT.EDU
  10. Organization: Hewlett-Packard Laboratories
  11. Lines: 28
  12. To: smneyln@ariel.lerc.nasa.gov
  13. Nntp-Posting-Host: hplchew.hpl.hp.com
  14.  
  15. In article <28JUL199210114546@ariel.lerc.nasa.gov>,
  16. smneyln@ariel.lerc.nasa.gov (Michael Neylon) writes:
  17. |>I have the following class...
  18. |>
  19. |>classs ARRAYBASE {
  20. |>private: float matrix[MAXSIZE][MAXSIZE];
  21. |>public: int xsize, ysize;
  22. |>    ARRAYBASE(int x, int y) {xsize=x+1;ysize=y+!;};
  23. |>// put + get handlers
  24. |>// overloaded operator= which is fine
  25. |>// Inverse() function, taken from _Num. Rec. in C_
  26. |>    ARRAYBASE ARRAYBASE::operator*(ARRAYBASE array1, ARRAYBASE array2)
  27. |>    {
  28. |>        //fill the array using matrix multiplication
  29. |>        //fill in matrix[][] and xsize, and ysize vars
  30. |>        return *this;
  31. |>    };
  32. |>};
  33. |>
  34.  
  35. since your * is  a non-static member function, it takes one argument
  36. (your array2).  Array1 will be
  37. the "this".
  38.  
  39. a function overloading * will take two arguments if it is a static
  40. member, or a non member function.
  41.  
  42. -Chee
  43.