#This time a ZTC++ bug?
/*————————————————————————
OK, this time I think I have found a bug in the Zortech compiler.
I get the following error message:
m11 = v.x ;
^
"gold2.cpp", line 29 Syntax error: member 'x' of class 'Vector' is private
I thought I took care of the privacy problem by making my classes mutually
'friendly' to one another! Again, if I switch the order of the 'Matrix'
and 'Vector' classes the file compiles with no problem. At this point I'm
coming up to speed with C++ and realize that I may need an additional
compiler/cfront, if for no other reason than to cross-check Zortech (…try
to get your boss to swallow that one!). Can anyone comment on the
Guidelines and Intek implementations of cfront? Are they direct ports or
brand new translators?
———————————————————————–*/
class Matrix ;
class Vector ;
class Matrix {
friend class Vector ;
private:
int m11 ;
public:
Matrix( int a11=0 ) ; //– constructor
Matrix operator*( const Matrix& a ) ;
Vector operator*( const Vector& v ) ;
} ;
class Vector {
friend class Matrix ;
private:
int x ;
public:
Vector( int a=0 ) ; //– constructor
} ;
Vector Matrix::operator*( const Vector& v )
{
m11 = v.x ;
return Vector( m11 ) ;
}
Matrix Matrix::operator*( const Matrix& a )
{
return Matrix( m11*a.m11 ) ;
}