[comp.lang.c++] friend function and derived class

shopiro@alice.UUCP (Jonathan Shopiro) (07/24/89)

In article <8907212152.AA13001@slcs.SLCS.SLB.COM>, saito@sdrvx1.sinet.slb.COM (Naoki Saito (GEO-002) Ext. 5471) writes:
- 
- 	Let me explain with the actual example.  Suppose we have a Complex
- class as in the libg++.  I want to create a Complex matrix class whose element
- consists of Complex.  Then I want to define conjugate function of the Complex
- matrix class as well as the Complex class:
- 
- In Complex.h,
- 
- friend Complex conj(Complex& z);
- 
- In ComplexMatrix.h,
- 
- friend ComplexMatrix conj(ComplexMatrix& Z);
- 
- I want to use the conj function of the Complex class in the definition of the
- ComplexMatrix's conj as follows:
- 
- for (i = 0; i < rows; i++)
-   for (j = 0; j < cols; j++)
-        ZC.buf[i][j] = conj(ZC.buf[i][j]);
- 
- However, this does not work.
This should work and it does work in C++ 2.0.  Complain to your compiler vendor.
-- 
		Jonathan Shopiro
		AT&T Bell Laboratories, Warren, NJ  07060-0908
		research!shopiro   (201) 580-4229