Domain Discussion Board

Go Back   Domain Discussion Board > General > Tutorials

 
Reply
 
LinkBack Thread Tools Display Modes
basic C++ tutorial....4 beginners
Old
  (#1 (permalink))
frih
Senior Member
frih is an unknown quantity at this point
 
frih's Avatar
 
Status: Offline
Posts: 194
Points: 536.4
Bank: 526.5
Total Points: 1,062.9
Donate
Join Date: Sep 2007
Rep Power: 0
Exclamation basic C++ tutorial....4 beginners - 08-20-2008, 05:34 AM

[SIZE=2]Why do People Program?

Each person can have his own reason for programming but I can tell you that programming is one of the best ways to gain a deep understanding of computers and computer technology. Learning to program makes you understand why computers and computer programs work the way they do. It also puts some sense into you about how hard it is to create software.

What is C++ & OOP?

C++ is an extended version C. C was developed at Bell Labs. in 1978. The purpose was to create a simple language (simpler than assembly & machine code...) which can be used on a variety of platforms. Later in the early 1980's C was extended to C++ to create an object-oriented language. O(bject) O(riented) P(rogramming) is a style of programming in which programs are made using Classes. A class id code in a file separate from the main program - more on classes later. OOP in general & C++ in particular made it possible to handle the complexity of graphical environments. (like windows, macintosh..)

What do I need to program?

Well, you need a computer and a compiler to start with but you also need some curiosity and a lot of time. I guess(!?) you have a computer. You can find different compilers for free from borlands website (Check 3.1). If
you have the curiosity but lack in time read stuff at lessons and detention hours. Read whenever you find time. Having a good C++ book (check 3.2) also helps a lot. (and is much better for your eyes) One thing not to forget: No tutorial, book, program or course makes you a programmer in 5 days. YOU make yourself a programmer. NO compiler writes an entire program for you, YOU write the program.

Running a C++ Program

A C++ program must be compiled and linked before it can be executed, or run, on the computer. A great lot of compilers do this automatically. So what is a compiler? A compiler is a program that translates C++ code into machine language. Machine language is the language consisting of 1s and 0s, and is the native language of a computer. A typed C++ program is called the source-code, and the compiled code is called the object code.

Before the object code can be executed, it must be linked to other pieces of code (e.g. included libraries) used by the program. The compiled & linked program is called an executable file. Finally, the program is executed by the system. It's output is displayed in a window.

C++ Program Structure

All C++ progs contain statements (commands) that tell the computer what to do. Here is an example of a simple C++ program:

/* Downloaded from Code.box.sk
We own you program */

#include <iostream.h>

int main()
{
cout<<"We own you"; // the first statement
return(0); // the second statement
}

Run the program. It should display :

We own you

The structure of a simple C++ program is:

************************************************** ***
* /* Comments : Name, purpose of the program
* your name, date, etc. */
*
* #include <librarynames.h>
*
* int main()
* {
* statements; // comments
* return(0);
* }
************************************************** ****

Now we will have a closer look on the structure:

Comments

Comments are used to explain the contents of a program for a human reader. The computer ignores them. The symbols /* and */ are used for the beginning and end of a comment for multi-line comments. // symbols are also used for commenting. All characters on a line after the // symbol are considered to be comments and are ignored. Most newbies think that commenting a program is a waste of time. They are wrong. Commenting is very important because it makes the code understandable by other programmers and makes it easier to improve a program or fix the bugs in it. You'll understand better after trying to decipher a hundred pages of code you wrote a few months later.

Libraries

Look at the program above. Following the opening comment was the line:

#include <iostream.h>

This line simply tells the computer that the iostream library is needed therefore it should be included. A library is a collection of program code that can be included (and used) in a program to perform a variety of tasks. iostream is a library - also called as a header file, look at its extension - used to perform input/output (I/O) stream tasks. There are a lot of non-commercial C++ libraries for various purposes written by good guys who
spent more than enough time in front of their computers. You can find them at code.box.sk. Also references to all libraries used in the tutorials can be found on the net.

Functions

The next line in the program was:

int main()

Which is the header of the main function. Makes sense? No? A function is a set of statements that accomplish a task. A function header includes the return type of the function and the function name. As shown in the main() header, main returns an integer(int) through return(0). So all the functions that have an integer as the return type returns integers. Very clear. The statements in a function (in this case the main function) are enclosed in curly braces. The { and } symbols indicates the beginning and the end of statements. More on functions later.

Streams

What is a stream? In C++ input/output devices are called streams. cout (we used above) is the c(onsole) out(put) stream, and the send (insertion) operator is used to send the data "We own you" into the stream. In the first statement:

cout<<"We own you";

The words following the << operator are put in quotation marks(") to form a string. When run, the string We own you is sent to the console output device. Yes, it is also called the computer screen.

***Important note: C++ is case sensitive. That means cout and Cout is not the same thing.

Return

The second statement was:

return(0);

which causes the program to terminate sending the value 0 to the computer. The value "0" indicates that the program terminated without error.

***Note : The statements end with a semicolon (. A semicolon in C++ indicate the end of a statement.


thanxxx[/SIZE]







[SIZE=2]rgards[/SIZE]
[SIZE=2]frih!![/SIZE]


Get Free Domain Now
visit-- http://www.geekquery.com/forum/index.php
   
Reply With Quote
Re: basic C++ tutorial....4 beginners
Old
  (#2 (permalink))
christyhl
Platinum Member
christyhl is an unknown quantity at this point
 
christyhl's Avatar
 
Status: Offline
Posts: 1,447
Points: 127.0
Bank: 816.4
Total Points: 943.3
Donate
Join Date: Apr 2008
Location: Next to the computer
Rep Power: 0
Re: basic C++ tutorial....4 beginners - 08-20-2008, 10:07 AM

! Very nice! I was searching for a C++ basics tutorial! I guess I've found it!
   

Reply With Quote
Sponsored Links
Re: basic C++ tutorial....4 beginners
Old
  (#3 (permalink))
dodo79
Executive Member
dodo79 is an unknown quantity at this point
 
dodo79's Avatar
 
Status: Offline
Posts: 371
Points: 0.0
Bank: 6,044.7
Total Points: 6,044.7
Donate
Join Date: Dec 2006
Rep Power: 0
Re: basic C++ tutorial....4 beginners - 08-23-2008, 02:15 AM

thank you alot for this good tut....................


----------------------------------------------
----------------------------------------------

Banner Exchange
   
Reply With Quote
Re: basic C++ tutorial....4 beginners
Old
  (#4 (permalink))
Platinum
Executive Member
Platinum is an unknown quantity at this point
 
Platinum's Avatar
 
Status: Offline
Posts: 263
Points: 785.8
Bank: 2,429.1
Total Points: 3,214.9
Donate
Join Date: Feb 2008
Location: hubbabubbamaxland
Rep Power: 0
Re: basic C++ tutorial....4 beginners - 10-02-2008, 01:27 PM

thats alot like the hello world!! but thanks


everything and anything you need - http://the-bankhead.net/
:)

   
Reply With Quote
Re: basic C++ tutorial....4 beginners
Old
  (#5 (permalink))
Platinum
Executive Member
Platinum is an unknown quantity at this point
 
Platinum's Avatar
 
Status: Offline
Posts: 263
Points: 785.8
Bank: 2,429.1
Total Points: 3,214.9
Donate
Join Date: Feb 2008
Location: hubbabubbamaxland
Rep Power: 0
Re: basic C++ tutorial....4 beginners - 10-12-2008, 07:23 PM

got any vb6 tutorials? like to see those.


everything and anything you need - http://the-bankhead.net/
:)

   
Reply With Quote
Reply


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

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

Points Per Thread View: 1.0
Points Per Thread: 15.0
Points Per Reply: 5.0


Similar Threads
Thread Thread Starter Forum Replies Last Post
FREE CGI Hosting blue-sky Wonderful Websites 21 04-27-2008 07:12 AM
Tip of an IceBerg - Getting Indexed Real Fast (1st Tutorial), Basic Guide The Winner Other Marketing Techniques 0 01-29-2008 05:18 AM
Basic Tutorial on How To Get Your Information Really Quick? weblord Chit-Chat Area - Internet Related 3 12-05-2007 05:28 AM
Link to PHP tutorial for beginners sarbaraj101 Member Help 7 09-05-2007 07:25 AM
All Programming Tutorials - Online For Ye All! hariharan Wonderful Websites 17 04-29-2007 05:22 AM


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 ©2007, Crawlability, Inc.