1 2 3 4 5 6 7 8 9 10
|
// my first program in C++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
|
1) a comment, has no effect on the compiler
3) includes iostream, which allows you to use cout and cin (there could be more, i don't know them)
4) because iostream is part of the std library, std::cout std::cin would be the appropriate way to write those commands without "using namespace std" there are downsides to using this when defining your own functions that may have the same function name as another function in the std library
6) the main function, it defines the point your program starts at.
7) opens the main function, anything past this but before '}' is included in this function
8) outputs "Hello World!" (mind you without the quotation marks) to your program
9) returns 0, a common way to say "if you have reached this point, no error has occurred"
10) see 7