all standard c++ code will work on all up to date compilers. As long as the code isn't using features not available to the tools, it will work -- for example you can't use c++20 features on a c++ 17 compiler because it didn't exist when the tool was built and won't work.
when you go off into third party libraries like visual's GUI stuff, it may or may not work (or may take a ton of effort to get it to work) on another tool.
> both of them used c++ which is the same language.
Standard C++ is the same language; however for complete portability, in addition to adhering to the standard and avoiding undefined behaviour, our code should not explicitly rely on implementation-defined behaviour (eg. sizeof(long double) or the type of std::time_t) or unspecified behaviour ( eg. the specific type of a lambda expression or its closure object).