Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Modern C++: The Good Parts/Anatomy of a global greeting

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Let's examine our program from last time in more detail. Code & explanation #include <iostream> #include <string> These includes are required by the standard, so anyone who wants to offer a proper C++ compiler must provide them. Several includes are required that way, and the set of them is called the standard library. <iostream> allows us to use std::cout and std::cin. All of our programs will include it, because they're all console programs. <string> is needed anytime you want a string (a value that represents text), which will also be all of our programs. int main() { std::cout << "Hello, world!\n"; } As mentioned before, int main is required for all C++ programs. Ignore the parentheses and curly brackets for now; just know that they're necessary. std::cout and std::cin are for console output and input, respectively. std is the namespace, which basically means who gave them to us, and this one is the standard namespace - i.e., these are from the standard library. The "c" just means C++ inherited them from its "parent" language, C. The "\n" at the end of the string is a line break or newline; it causes further text to be printed on an additional line. Vocabulary standard library several useful pieces of code required by the C++ standard, shipped with all C++ compilers, all under the namespace std. string a value that represents text. namespace a directory of names, or where to look for something by name. newline a character which separates two lines of text. Also called a line break. Syntax: \n Hello, world! The world's response