Tuesday, December 5, 2006

Beginning C++ Programming: Lesson 1

This week's video covers how to create your first C++ program. Hello World is usually always the first thing that is taught in a programming class because its a very basic program but also gives the student a feeling of actually creating something. Below are links to the youtube video and a link to download the video from megaupload since youtube really kills the quality of the video.

Youtube Link:
http://www.youtube.com/watch?v=K5HdaQ5b9cQ

Megaupload Link:
http://www.megaupload.com/?d=DKZOUNJ5

Lesson 1 Source Code:
http://www.megaupload.com/?d=QST91O38

Video Explanation:

In the video I mentioned the header file called iostream this has to be included into any program that requires input and output if you don't put this header file in your program your compiler will give you an error that says:

'cout' : undeclared identifier

this just means that the object "cout" can't be found because the header file in which it is contained doesn't exist. When you download the source file try doing this comment out the #include line and see what you get.

BTW I forgot to mention on the video but you create comments by just adding // in front of the line you want to comment out if you are using Visual Studio the line should now turn green.

cout and inseration operator:

cout is the output object in the iostream header file it just tells the compiler to output the data that is being inserted into the output stream. The insertion operator "<<" is what actually inserts the value into the output stream buffer. You can have pretty much any type of value here you want. If its a string it must be enclosed in quotes as in this example but you can also output variables which I will cover next time.

The return 0 statement just tells the main function to return the value of zero to windows. The Zero value just means that your program has ended smoothly.

All C++ statements must end in a semicolon!!!


Next Week's Video:

I will expand on this example and show you how to get input from a user and explain what variables are.