0

Why do we need to do usingnamespace std and what is int main and why we use it?

Well my question is the title please,please answer Im a 12 year old trying to learn C++ Example to help you: #include <iostream> using namespace std; int main() { cout << "Hello world!"; return 0; }

18th Nov 2016, 12:46 AM
Aidan Toussaint
3 ответов
0
using namespace std prevents from having to do std:: in front of thing like cin, cout, endl, etc. int main is the, as it says, main function of your program. This is where everything starts.
18th Nov 2016, 12:54 AM
scott johnson
scott johnson - avatar
0
std is the standard namespace of c++. If hadn't put it there you had to write for example std::cout for printing. std is the namespace of the standard c++ library. You can use other namespace and define your own - but that is only important for large projects. You will be fine in std for a while. int main ist the main function of a c/c++ program. If you want to have runnable code - you will need this function. it's int - because main returns an integer - it's standard to return 0, if your program runs fell or return with some failure value if something had gone wrong.
18th Nov 2016, 1:18 AM
Niels Ringelmann
Niels Ringelmann - avatar
0
My Advice Just forget about it and keep moving forward ...when you start module on classes and object you will be able to use #include and namespace
18th Nov 2016, 1:57 AM
Maxwell Miles
Maxwell Miles - avatar