The burden of checking out C++ files lies with the IDE, so you need to hook your chosen IDE up to Perforce so it can handle checking out files for you; the engine won’t handle that as you’re not changing those files from the editor.
I’m unfamiliar with how Visual Studio handles Perforce, but JetBrains’ Rider handles it okay, it’s just a bit of a pain in the rear to get it to play with your Perforce session.