There’s a few tutorials kicking around here; I followed them and am working with C++ and CubeMX generated projects just fine.
Here’s a couple of points you’re not going to get until you do some reading.
(1) C and C++ link differently. C++ uses a thing called name mangling. You need to be careful in keeping your C and C++ code in separate sources files if you can manage it. Google for the exact phrase ‘extern “C” and calling C from C++’ and you will get hours of relevant reading material.
(2) if you’re using CubeMX, don’t fight the code generator; note the “user code goes here” sections, put your C++ code in a different folder and add that folder to your includes in the compiler settings. You’ll have much more success if you do that because then you can regenerate your code with CubeMX without mangling all the work you did to get the C++ linkage working.
I will see if I can do a simple “hello world” c++ example at some point because I have a project template that’s working well for me now.