J
John
MSVC6 (SP5) gives this error when I try to use a non-pointer type to a class
that is forward-referenced:
reo.cpp(8) : error C2027: use of undefined type 'B'
However Borland's free 5.5 compiler successfully compiles the same code
snippet.
/* ----------------------------- */
class B; // forward reference
// class A references B
class A
{
public:
void fn(B b) {} // ##### MSVC6 gives error, whereas Borland does not
#####
};
// class B references A
class B
{
public:
void fn(A a) {}
};
void main() {;}
/* ----------------------------- */
The Microsoft compiler will work if I alter the code by changing the
parameters into pointers (seems the forward ref works with pointers only).
However Borland's forward references work with either way.
I have to assume there is a way to make this work in MSVC6 without altering
the code.
Your suggestions and any helpful pointers (no pun) would be appreciated.
TIA,
--John
that is forward-referenced:
reo.cpp(8) : error C2027: use of undefined type 'B'
However Borland's free 5.5 compiler successfully compiles the same code
snippet.
/* ----------------------------- */
class B; // forward reference
// class A references B
class A
{
public:
void fn(B b) {} // ##### MSVC6 gives error, whereas Borland does not
#####
};
// class B references A
class B
{
public:
void fn(A a) {}
};
void main() {;}
/* ----------------------------- */
The Microsoft compiler will work if I alter the code by changing the
parameters into pointers (seems the forward ref works with pointers only).
However Borland's forward references work with either way.
I have to assume there is a way to make this work in MSVC6 without altering
the code.
Your suggestions and any helpful pointers (no pun) would be appreciated.
TIA,
--John