Not Just Paranoid

Another site by Pete Maynard

C++ #1

Okay to start programming in C++ you need to have a compiler. A compiler turns your source code into binary computer talk. The best compiler for you if your running Linux will be g++ (Just type g++ <filename>, in the terminal), or if your on Windows you might want to try Dev C++. Dev C++ is an IDE, which stands for Integrated Development Environment, an IDE combines the editor, compiler and other useful tools in the same software package.

Right now that you have downloaded your compiler/IDE. You want to learn some C++. To start with I will explain how to do this in Ubuntu 7.10 and I might if your lucky quickly go through how to set up and run Dev C++, but that’s not hard. If you are following along in using an IDE then you just type the code into it and click on compile and then run.

Now to write a simple “Hello World!” example.

#include <iostream>

main()
{
    std::cout << "Hello World!";
    return 0;
}

Line one (#include <iostream>) is needed so that you can use the std::cout command

Line Two is the main function, which needs to be in all programs, it’s the function that gets called first. And then anything the the curly braces runs.

Line three is the command that prints out the text to the screen

Line four tells the computer that the program has finished and everything is okay and happy with dogs and cats all over the place

Erm yeah that’s about it. Not really very helpful, but I have ran out of time. I will either edit this or make a new one. Bye for now.

8 Dec 2007

Website Last Updated on 15 Sep 2023 (CC BY-SA 4.0)

This site uses JQuery and nanogallery2 hosted by jsdelivr.net
for the Flickr photo feed and GoatCounter for user insights.