 Originally Posted by A Roxxor
Code:
using namespace std;

 Originally Posted by mrdeano
Code:
#include "stdafx.h"
#include <iostream>
They tell the compiler to include these in the .exe
They are both separate files containing code.
stdafx.h is a header code and isostream contains different packages that do several things.
Yes.
Code:
using namespace std;
Tells the computer that it wants to use the package 'std' from ;isostream
... kind of... That tells it to use the std namespace throughout the program. It is considered better programming technique to only have a namespace over small scopes. It actually allows you to transcend scope, this is very useful in large programs so that you don't have duplicate variables and have to worry about concurrency.
Is the main function which every piece of code should have.
Yes, it's the entry point of the operating system, there is more to it, but you don't need to know that unless you are doing assembly optimizations.
Code:
cout << "Here is some text";
'cout <<' gives the program a output, or something to print. In this case its a line of text.
Cout is a keyword taken from the package 'std' which is in 'iostream;
'endl' ends the line
Yes, cout is a stream that goes to the terminal, the real thing that you need to take away from that line is the << operator. There are lots of functions that use it, you can create classes and use STL libraries to send strings through pipes, files, even the internet.
endl is a std const for cross compatibility, most programers use \n instead though, even though we shouldn't 
This makes the program wait for an input by the user
Yes, more specifically keyboard input, inputs from other devices won't trigger this method.
Once it has the input, it tells the computer to revert back to what it was doing before hand
Kind of, it tells the operating system to close the program and return an error code of 0. Returning things other than zero from the main loop tells the operating system that something went wrong, and depending on the code and the OS, it may attempt some type of recovery. From -127 to -1, the system may try a recovery, from 1 to 127, it is a user-defined error and will not produce any type of recovery on the OS level, it may be read by a calling or forking program though.
|
|
Bookmarks