#This time a ZTC++ bug?
3 messages in this thread
/*————————————————————————
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 ) ;
}
Your right, thats a bug. I compiled it in Zortech and got the same error,
then tried it on cfront and it compiles without error. What you are doing
is perfectly legal. You should probably report that to Zortech technical
support…
yup, that is an error all right. I can see what is going wrong. I'll pass
your problem along to Walter & co.
Yea, get another compiler and use it as a LINT checker. Zortech does not
report as many errors as it should, and it is nice to make sure the code
will compile under Cfront all along incase you run into a wall and ZTC
becomes unusable suddenly. However, I think Comeau Computing is the only
one out now. That is the one I would recomend anyway– only $250. Glock
has not gone into beta yet and Guidelines shouldn't have. Don't know about
Intek off hand.
–John