#C++ Forward Referencing
/*————————————————————————
Some C++ questions:
The attached code gives me the following error under Zortech C++ v2.06.
m11 = v1.x ;
^
"test.cpp", line 26 Syntax error: member 'x' of class 'Vector' is private
I have tried to get support from Zortech to no avail. Am I doing
something wrong in C++ or is it a compiler bug? I found that if I
re-order the file such that the Matrix class preceeds the Vector class,
the program compiles without a problem. I thought I had taken care of the
forward referencing, though. Is this a bug, or is it me?
Thanks, Bob Goldrich
———————————————————————–*/
class Vector ;
class Matrix ;
class Vector {
friend void Matrix::trans( const Vector& v1 ) ;
private:
int x ;
public:
Vector( int xx=0.0 ) ; //– constructor
} ;
class Matrix {
int m11 ;
public:
Matrix( int a11=0.0 ) ; //– constructor
void trans( const Vector& v1 ) ;
} ;
void Matrix::trans( const Vector& v1 )
{
m11 = v1.x ;
}