Lesson 1-2 on C++.Docx

Topics: Assignment, Equals sign, Source code Pages: 17 (4109 words) Published: January 29, 2013
Lesson 1: The basics of C++

This tutorial series is designed for everyone: even if you've never programmed before or if you have extensive experience programming in other languages and want to expand into C++! It is for everyone who wants the feeling of accomplishment from a working program. 

What do I mean? C++ is a programming language--it will allow you to control your computer, making it do what you want it to do. This programming tutorial series is all about helping you take advantage of C++. Getting Set Up - C++ Compilers

The very first thing you need to do, before starting out in C++, is to make sure that you have a compiler. What is a compiler, you ask? A compiler turns the program that you write into an executable that your computer can actually understand and run. If you're taking a course, you probably have one provided through your school. If you're starting out on your own, your best bet is to use Code::Blocks. Our page on setting up Code::Blocks will take you through setting up the Code::Blocks compiler in great detail. Advanced Compiler Details

If you've got some prior experience, or just want a menu of choices, you should know that there are several common compilers. If you're new to programming, just skip this section! 

Some common compilers include Borland C++, Microsoft C++, and GNU C++. 

There are also many front-end environments for the different compilers--the most common is Dev-C++ around GNU's G++ compiler. Some, such as G++, are free, while others are not. Please see the compiler listing for more information on how to get a compiler and set it up. 

Each of these compilers is slightly different. Each one should support the ANSI/ISO standard C++ functions, but each compiler will also have nonstandard functions (these functions are similar to slang spoken in different parts of a country). Sometimes the use of nonstandard functions will cause problems when you attempt to compile source code (the actual C++ written by a programmer and saved as a text file) with a different compiler. These tutorials use ANSI/ISO standard C++ and should not suffer from this problem (with sufficiently modern compilers). Note that if you are using an older compiler, such as TCLite, you should read check out some compatibility issues.  Intro to the C++ Language

A C++ program is a collection of commands, which tell the computer to do "something". This collection of commands is usually called C++ source code, source code or just code. Commands are either "functions" or "keywords". Keywords are a basic building block of the language, while functions are, in fact, usually written in terms of simpler functions--you'll see this in our very first program, below. (Confused? Think of it a bit like an outline for a book; the outline might show every chapter in the book; each chapter might have its own outline, composed of sections. Each section might have its own outline, or it might have all of the details written up.) Thankfully, C++ provides a great many common functions and keywords that you can use. 

But how does a program actually start? Every program in C++ has one function, always named main, that is always called when your program first executes. From main, you can also call other functions whether they are written by us or, as mentioned earlier, provided by the compiler. 

So how do you get access to those prewritten functions? To access those standard functions that comes with the compiler, you include a header with the #include directive. What this does is effectively take everything in the header and paste it into your program. Let's look at a working program: -------------------------------------------------

#include <iostream>

using namespace std;...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Assessments 1 2 2014 Docx 1 Essay
  • Essay on EGT 1 Task 2
  • Essay on ERR 1&2
  • Essay on EBT 1 Task 2
  • CU678 Units 1&2 Essay
  • Essay on C+++ Basic Lessons
  • Module 5 Lesson 2 Assignment 1 2 Essay
  • Lesson 2 Essay

Become a StudyMode Member

Sign Up - It's Free