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
    forums
Old 02-16-2003, 06:26 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
Hello World

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.
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
S. Korea leads world in Net speed sde Code Newbie News 1 12-22-2003 05:24 AM


All times are GMT -8. The time now is 02:05 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting