Java is a "modern" compiler. Modules are correctly compiled, including their cross-references. C++ is an "old" compiler, smart enough to do everything in a single pass over the source code. However, this implies that it will let you reference A from B, and even B from A, provided that you only use pointers to them. Actually, when C++ compiles A it does not know that you there is a B class. Okay, we can fix this by preceding the declaration of A with:
class B;
Which equals to say to the compiler: okay, there is a B class somewhere else. Fantastic. Now you can put parameters of the kind "B* b", because a pointer is just a pointer (4 bytes in 32bits architectures...). However, you won't be able to compile something like, say, a parameter-by-value "B b", because among other things, the compiler needs to know the size of the class B, as it hasn't even compiled it yet.
There are other considerations about your code, specially about passing this, (this is a pointer), but those aspects have been answered yet.