I see your point. It's a bit of an extreme example, but I do get your point.
Simpler version is that any real world C++ source depends on implementation of compiler (less so these days) and the OS (down to version) it runs on.
Consider a simple DX example - it implies version of Windows, version of Visual Studio and version of DX. You could copy paste it, but unless you replicate the environment, chances are it won't compile, won't work correctly or will have subtle bugs.
Ideally, all code would seek to minimize external dependencies, but in practice it's too expensive.
Same applies to, say, Python which depends on VM version and implementation (2 vs. 3, CPython, PyPy, Jython, ...) as well as any hidden dependencies, such as native C code used by project. But all of these would be called Python code and snippet might be copyable between them.