The C++ language has two main components: a direct mapping of
hardware features provided primarily by the C subset, and zero-overhead
abstractions based on those mappings. Stroustrup describes C++ as "a
light-weight abstraction programming language [designed] for building
and using efficient and elegant abstractions";
[5]
and "offering both hardware access and abstraction is the basis of C++.
Doing it efficiently is what distinguishes it from other languages".
[33]
C++ inherits most of
C's syntax. The following is Bjarne Stroustrup's version of the
Hello world program that uses the
C++ Standard Library stream facility to write a message to
standard output:
[34][35]
#include <iostream>
int main()
{
std::cout << "Hello, world!\n";
}
Within functions that define a non-void return type, failure to
return a value before control reaches the end of the function results in
undefined behaviour (compilers typically provide the means to issue a diagnostic in such a case).
[36] The sole exception to this rule is the
main function, which implicitly returns a value of zero.
[37]
No comments:
Post a Comment