So, if I pay for the compiler I will be able to compile this simple program.

No. Your program is written in C++. The Keil C51 is a C compiler. It will compile programs written in C, but not programs written in C++, Pascal, Fortran, Oberon, Smalltalk, or any other programming language that is not C.

Why is the demonstration version so limited?

The limits of the evaluation verison have nothing to do with the "problem" you have encountered.

Microsofts free compiler can do so much more!

Microsofts compilers cannot produce output that will run on an 8051. If you need your programs to run on an 8051, you will need to use something other than a Microsoft compiler.

So can you recommend to me a good cheap compiler that can do this simple job?

A free/cheap C++ compiler for the '51 ? Sorry. There is a C++ compiler, but it's not cheap or free. There are free compilers, but they do C, not C++.

How about you switch to programming in C instead of C++ ? Then you will have plenty of options. Maybe the evaluation version of Keil will actually suffice for what you are trying to do.