Re: Managed code, .H and .CPP



Ignazio wrote:
> Thank you. If I understood well, I can write all the code of the
> forms in their .H without any problem.
> The only problem is with cross-dependance of two classes. For example:
>
> // A.h
> #include "B.h"
>
> ref class A {
> void f () {
> B::g();
> }
> void g () {
> Console::WriteLine("test");
> }
> };
>
> // B.h
> #include "A.h"
> ref class B {
> void g() {
> A::g();
> }
> };
>
> The compiler encounters an error, as it is right to do in C++. So, it
> is necessary to write a header and a cpp file for one of the two
> classes... Don't you find it a little tricky that I need just the .H
> for some files and both for other files?

Yep.

You can thank C++'s one-pass compilation model for that. Until (and unless)
C++ adopts a multi-pass compilation model we'll always have that limitation.

-cd


.



Relevant Pages


Loading