Question: I know that for running c++ on Windows you need to compile specifically for Windows and the same goes for linux and on...

But for example, if I'm compiling program for Windows written in native c++ I can run it on a freshly installed windows pc? I mean, without downloading visual c++ runtime libraries, etc, I can just compile it, let's say, reinstall windows on my computer, and run it without installing anything else?

(The question above using Windows as an example but the same thing can be done on freshly installed linux distro? e.g Ubuntu)
Thanks in advance.

Answer: 
No. Often the libraries are different on different systems. If your program involves any GUI then you will definatly have OS specific code that won't run on other OSs.

If you write a C++ program targeting the g++ compiler without GUI code there may still be some OS specific code. But you should be able to port it with minimal effort.

If your program only uses stl and stdio, then it will probably be portable. For example, MS STL's ::c\_str() function works a little different than the linux one.
For what it's worth, when using MinGW with static linkage to libc and libc++, It's very likely that your C++ application will work on any Windows system '95 and later, unless you specifically enabled functionality in the Windows API that isn't available, like NT features. All of my SDL applications compiled for Windows 7 (compiled in 32 bit of course) work fine on my '95 machine.

When deploying a Linux application, it's best to just supply the source plus a configure script or makefile. This will ensure that the user has valid dependencies for your application. You could deploy binaries to specific package managers if you wanted to though.