Manual:C++
From FSDB
This tutorial is currently under construction. Please don't mess with it until this message is removed. |
Here you can find information and resources for the C++ programming language. If you'd like to learn C++, but don't know where to start, this might be useful.
This tutorial is still a work in progress. If you have any comments or suggestions, please let me (CodeCat) know.
Special thanks to Burning Sheep Productions for giving me some incredibly useful feedback!
About this tutorial
This tutorial attempts to teach most of the basics of the C++ language, so that after completing it you can either read up more, or practice by making some simple programs. Since the C++ standard only contains support for text-mode console programs, this tutorial will focus only on that. If you want to start writing graphical programs or games, you should look for further reading on those subjects after finishing this tutorial.
The initial part of the tutorial attempts to cover the language from the inside out. First it covers variables, data types, constants and so forth. Then come the control structures, such as loops, followed by some other important and useful data types. Then it covers functions, and finally, classes. Any remaining concepts such as arrays and pointers are covered after that.
This may seem unusual to those who have already read other C++ tutorials, but the tutorial is set up like this for a reason. It is primarily geared towards a practical understanding, and tries to teach good practice first rather than more basic concepts first. So the vector data type is covered before arrays, because vectors are safer to use and easier to manipulate, hence more 'beginner friendly'. Arrays are also closely tied to pointers, and pointers are themselves a more advanced subject in C++.
This tutorial also covers some parts of the revised C++ standard, C++0x. Although this standard hasn't been released yet and may still change, some compilers (notably GCC) already support some of its additions. Features that are not available in current (standard) C++, but will likely be included in C++0x, are shown in this colour.
Part 1: Basics
Chapter 1: A first look at C++
- Welcome to C++
- Introduction to programming
- Getting started
- Hello, world!
- Organising your program
- Understanding the compiler
Chapter 2: Variables and types
Chapter 3: Simple programs
- Expressions and operators
- Strings
- The cout output stream
- The cin input stream
- Type conversions
- Casting
Chapter 4: Control structures
Part 2: Functions
Chapter 5: Working with functions
- Defining and calling functions
- The void return type
- Scope and local variables
- Global and static variables
- Function prototypes and declarations
Chapter 6: Advanced functions
Part 3: Types and classes
Chapter 7: Defining new types
Classes and objects
- Classes and objects
- Constructor, destructor
- Copy constructor, move constructor
- Operator overloading
Inheritance and polymorphism
- Inheritance, friends
- virtual / polymorphism
- dynamic_cast
Part 4: Arrays, pointers and files
Container classes
- Working with strings
- vector, list, deque
- map, set
Pointers and dynamic memory
- Pointers
- Pointer arithmetic
- new / delete
- reinterpret_cast
Arrays and bitfields
- Arrays
- Char arrays
- Octal and hexadecimal literals
- Bitwise operators
Files and streams
- Streams, files, stringstream
- Formatting output, manipulators
Part 5: Advanced language features
- Templates (function, class)
- Standard mathematical functions
- Date/time
- Complex
- namespaces
- Exceptions
- Preprocessor
- Working with headers (declarations, extern)
- Mixing with C code
