Last active
March 20, 2017 16:27
-
-
Save AndyNovo/4986f1d458ba0bb70d61f2cc7d1fdf27 to your computer and use it in GitHub Desktop.
Basic C++ Hello World
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
//Note that there is a different input/output library iostream | |
//Also a slightly different notation for including <libraryname> instead of "libraryname.h" | |
//Again there is a "main" function with a return type "int" | |
int main() { | |
//Now printf is replaced by a "stream" concept, where "cout" is the output stream | |
//and we pipe values into that output stream by the "<<" operator. | |
//Also the "\n" has a more abstract version "endl" for a platform independent newline character | |
std::cout << "Hello World!" << std::endl; | |
//Finally you'll note that there is a "std::" namespace in front of the cout and endl keywords. | |
//We can do away with that by having a "using namespace std;" line higher in the code | |
//Or even a "using std::cout;" and "using std::endl;" lines higher in the code. | |
//In those cases just 'cout << "hello" << endl;' would work | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment