I'm conflicted about this.
On the one hand, I don't like the off-site links any more than you do, believe strongly that all code should be in the question itself, and don't much care for the clutter of useless #include
s, etc. in the name of building up an MCVE (over-emphasis on complete).
But on the other hand, I'm not convinced that your proposal is really useful enough to justify developer time to build. Is it really that hard to just copy and paste a few different blocks into a text editor? I can do it in mere seconds. Besides the development time, each time a person composes a code-based question, they would have to prepare this "invisible" code snippet and ensure that it gets formatted correctly. Perhaps I'm more cynical than you, but people have a hard enough time getting code that they can see in the question itself formatted correctly; what are the odds that they'll get the formatting correct for invisible code that manifests only when copied and pasted?
I've never had an issue copying and pasting code out of posts directly from the rendered view, but even if something goes wrong there, the "edit" link can always be used as an escape hatch to get the raw, unformatted, plain-text view, and then work from there.
If something like this does get implemented, it would probably make more sense to do it by expanding the "Stack Snippets" feature. You may never have heard of this, given your C++ focus, but it's something they introduced a couple years ago that allows embedding and running code for "webby" languages (HTML, CSS, and JavaScript) directly in a post. It could theoretically be expanded to display, compile, and run code for C and C++, which might solve some of the problems you describe. Of course, this wouldn't be a trivial undertaking, because unlike JavaScript, C++ can't be compiled directly in the browser, so they would need a server to run a compiler. It's obviously doable, since there are so many other services that do it, but again, I'm not sure it's worth the development effort. I personally wasn't even sold on the benefits of Stack Snippets for JS/HTML/CSS, and although I don't spend much time asking or answering such questions, I have read a fair number of them as aids to my own feeble pursuits, and I haven't found this feature to be especially useful. It mostly just takes up valuable screen real-estate, obscuring the code I want to see. I inevitably copy and paste the relevant code into my own demo harness anyway, where I have complete control. I'd say the same would probably be true, if not even more so, for a compiled language, where I'd want to have precise control over the compiler/optimizer/linker options.