The secret to getting things in the right order in C++ is to think in terms of translation units rather than files.
A translation unit is a cpp file like your main.cpp with all the included headers pasted in, just as if you'd copied and pasted the content of each file into the exact place where you have a #include for it and then done that again with the resulting code until the whole thing is one huge file. This craziness is exactly what the C preprocessor does with your code as a first step before compiling really gets going.
This pasted together super file is the thing that actually gets compiled and its the order of things in there that matters.
There's not enough of your code in your post for me to tell exactly whats wrong but a very general solution often ends up looking something like this.
That's the compilation unit for A.cpp. As you can see the one for B.cpp will be similar assuming that the A.cpp and B.cpp files as typed each begin with:
Forward declaration and the way inclusion works is a very old fashioned and cranky but very powerful tool for doing all sorts of things once you get a handle on it. Removing it from C# was one of the reasons I tend to stick with C++. Probably because I'm old fashioned and cranky too.