Hem   Mina vänner   Intressanta saker Information   Övrigt
Information
  Förstasida
  Programmering
  Rollspel
  Steve Jackson Games

Chapter 2 - C++ is a language

The core of any MS-DOS program written in the programming language C++ must look something like this:

main ()
{
}

Now, just what the he- does that mean? Well we just named (created a shorting) a piece of code. In this case we named everything within the curly brachets (nothing, that is) to 'main ()'.

Whenever the name of something in c++ ends with brachets (such as 'main ()'), no matter if there's something within those brachets or not, it is a so called function. It's just as in math really: y(x) means y is a function doing something with the variable x, but since we're not going to do anything with any specific information we don't put anything within the brachets here.

If we want our program to be executable, such as an EXE-fil (called that because the file name usually ends with '.exe') it has to be compiled. A compiler is a program that knows what the code means and can translate it into 'computer language'... the ones and zeroes. A c++ compiler will make sure that whatever is named 'main ()' will be executed when the compiled file is.

< Previous Chapter | Next Chapter >

 

Johan Thorstensson, 2003©