Re: The greeting code in Java
Supersedes: <C++-20110619225034@ram.dialup.fu-berlin.de>
Joshua Cranmer <Pidgeot18@verizon.invalid> writes:
C++ stack constructed-objects, references, #include (trust me, beginners
can get very confused about #include, as simple as it looks), and
Well, in my own classes, the explanation I give is this:
1. When a program uses certain names, it also needs to
have a corresponding #include line at the start.
For example, when a program uses ?::std::cout?,
?#include <iostream>? is required.
2. Here is a list of names and the #include-lines needed:
::std::setprecision #include <iomanip>
::std::fmtflags #include <ios>
::std::boolalpha #include <ios>
::std::streamsize #include <ios>
::std::ostream:precision #include <ios>
::std::cout #include <iostream>
...
And, naturally, any talk of C++ being simpler becomes hard to stomach
To explain the program, one would need to explain how the
operator << can be combined to the expression with two <<'s
(this has to do with the value of the operation, but then
one also needs to explain while in ?if( ::std::cout << 2 )?
it has a totally different value), but that there is no
sequence points, so that one has to be careful with side
effects and how actually the operator << is resolved
although it is not defined in the global namespace, which is
only made possible by ADL, which many experts have
difficulties to explain, because its rules are quite
complicated, then also, how << is overloaded for different
argument types, and why the statement
::std::cout << 4<2 << '\n';
gives and error, but why the expressions
4 << 2
is possible, although ?4? is no stream at all.
The new C++ standard has more than 1300 pages, but this is
base on the C standard with more than 500 pages. These are
nearly 1900 pages of a text in a condensed technical
language, yet the language does not allow to access a
directory of the filesystem or a socket of the network.