top | item 33394474

(no title)

Sin2x | 3 years ago

You need to include iostream

https://en.wikipedia.org/wiki/Input/output_(C%2B%2B)#Input/o...

discuss

order

tialaramex|3 years ago

The point is the code they cited is relying on a C++ 23 feature (standard modules) which isn't yet ratified (hence the name C++ 23) and nobody yet completely implements.

If you had standard modules, then the import line at the top of that code does get you all of std, including std::cout and thus the I/O streams.

This example is still silly if you do have C++ 23 though because I/O streams are (say it quietly) basically obsolete in C++ 23 since it has a proper imperative print format feature like any modern language - with decent performance and all the format behaviour you're used to from other modern languages.

I expect that, when C++ 23 becomes a thing lots of people actually use, the canonical "Hello, world" example for it will use std::println()