Let's start first C++ program with "Hello World!"
#include <iostream> using namespace std; int main() { cout << "Hello World!"; return 0; }
Let's discuss code line by line.
- First line includes library iostream, which is required to handle input-output. This library need to include because it is not part of standard C++ Library.
- In second line used to add namescpase. namescpase is group/region of classes, public method and public variables. Here we are using std Library, means C++ standard library.
- int main() is first function in C++, which will call first while execution. int is return type, which will return program status to outside world. Default return type in C++ is int. We can use void also.
- cout is the object of class ostream. It uses operator overloading to print "Hello World!".
- return 0 is status to other program from current program. 0 means successful execution. Non-zero value for error code.
Good that you started
ReplyDelete