Templates and forward declarations
-
As we all know, forward declarations are necesary to implement circular references, like below: struct A; struct B { A * a; }; struct A { B * b }; My problem is, how do i deal with this using templates? The following pice of code is a syntax error in VC++ 6.0: template struct A; template struct B { A * a; }; template struct A { B * b }; Does anyone know th correct syntax? :confused: Jonas Pettersson
-
As we all know, forward declarations are necesary to implement circular references, like below: struct A; struct B { A * a; }; struct A { B * b }; My problem is, how do i deal with this using templates? The following pice of code is a syntax error in VC++ 6.0: template struct A; template struct B { A * a; }; template struct A { B * b }; Does anyone know th correct syntax? :confused: Jonas Pettersson
Hmm, this discussion group does not seem to support brackets, they didn't get posted. I'll re-write the question using parenthesis as brackets... ------------------------------------------------------------------------------------------ As we all know, forward declarations are necesary to implement circular references, like below: struct A; struct B { A * a; }; struct A { B * b }; My problem is, how do i deal with this using templates? The following pice of code is a syntax error in VC++ 6.0: template(class C) struct A; template(class C) struct B { A(C) * a; }; template(class C) struct A { B(C) * b }; Jonas
-
Hmm, this discussion group does not seem to support brackets, they didn't get posted. I'll re-write the question using parenthesis as brackets... ------------------------------------------------------------------------------------------ As we all know, forward declarations are necesary to implement circular references, like below: struct A; struct B { A * a; }; struct A { B * b }; My problem is, how do i deal with this using templates? The following pice of code is a syntax error in VC++ 6.0: template(class C) struct A; template(class C) struct B { A(C) * a; }; template(class C) struct A { B(C) * b }; Jonas
I don't get template-related syntax errors when compiling the code in VC6 after simply changing the parentheses to brackets...there is a missing semi-colon after B* b in struct A, but other than that, no problems. (I'm able to create instances of the structs, too; link and running is no problem.) Walter Gildersleeve Freiburg, Germany walter.gildersleeve@pe-gmbh.de