> why has the standard not allowed doing that ??
The standard allows two different kinds of C++ implementations.
A hosted implementation is an implementation with full support for both the language and the standard library. This is the kind of implementation that runs under an operating system; the one that is almost always used .
A freestanding C++ implementation is one with language support, but no support the standard library (except for the few mandatory language-support headers). This is the kind of environment that may be present in certain low-end embedded systems.
|A freestanding implementation is one in which execution may take place without the beneﬁt of an operating system, and has an implementation-deﬁned set of libraries that includes certain language-support libraries |
In a hosted implementation, main()
is the designated start of the program and must conform to the requirements specified by the standard. (One of them being: main()
must return int
In a freestanding implementation, start-up is implementation-deﬁned; there need not be a main()
at all; and if there is one, it need not return int
To put it somewhat simplistically, if you havestd::cout
, you must also have main()
and it must return int