https://godbolt.org/z/fTPM35Erq
As the "C code" is also valid C++.
> A simple C program might print ‘hello world’ on screen:
> ....
> You can write the equivalent in C++:
He could keep using his original C example and simply change from gcc into g++.
But then he wouldn't be able to use "C is better than C++", when using stdio for both languages.
Note that in most cases, the speed of writing to standard output is irrelevant unless you are implementing cat or some command line text processing tool.
I find iostream very convenient and type safety is a big plus compared to printf. It’s also very easy to implement your own handlers for your own types.
Iostream do use virtual functions but it’s not the reason of its suboptimal performance. The main reason is that some strings will be copied, allocated and freed during the construction of the whole expression while printf can do its processing with minimal dynamic allocations.