Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    cpp
  » Hello World
      by sde
 Page 1 of 1 
   

(Login to remove green text ads)
A basic introduction to the most basic elements of C++

This tutorial was designed for Visual C++ 6.0, but it should work with any other ANSI comptible IDE. We will now create a Hello World program in C++ and explain every line of code along with it.
Code:
#include <iostream> using namespace std; int main() { cout << "Hello World"; return 0; }
Lets start with the first line. iostream is a library that is standard in c++. Libraries are usually a set of classes that define what certain objects do. In this example, the library "iostream" is needed for the "cout" (console out) function.

Since we can create other functions named "cout", line 2 defines that we are not using our own cout function, but the Standard set of namespace functions.

Let's look at line 4:
Code:
int main() { return 0; }
int main() is defining a function named "main". The "int" means that this function will return an integer. When the program runs and completes, it will "return 0" and the program will be complete.

Now let's look at line 6:
Code:
cout << "Hello World";
cout is a function that will print text to the console screen. Each statement should always end with a ";" in c++. ( much similar to other languages )

This is a pretty basic tutorial but important to understand before you move on.




 
 Page 1 of 1 
   

Rate This Article
1 2 3 4 5 6 7 8 9 10





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle