Search Engine

Google
 

Friday, January 12, 2007

C++ Resources and Tutorials

Starting out
Getting StartedTutorialsQuizzes
Moving on
Advanced TutorialsArticlesChallengesContestsTips and TricksJobs
Tools
What do I need?CompilersEditorsDebuggers
Resources
Source CodeSyntax ReferenceSnippetsLinks DirectoryGlossaryBook ReviewsFunction Lookup
Questions
Programming FAQMessage BoardAsk an ExpertEmail


Programming Tutorials
A C++ tutorial and a C tutorial, OpenGL with C++ tutorials, C++ Standard Template Library (STL) tutorials, articles on both the C and C++ programming languages and computer science, as well as Denthor of Asphyxia's graphics tutorials converted to C++ (mainly C code). Please email me with corrections or submissions to this page. Would you like to use these tutorials on your site?
Programming Tutorials Map
Beginner tutorials
C++ Made Easy
C Made Easy
Advanced Language Features and Concepts
Tutorials on advanced C and C++ features
C++ Standard Template Library (STL) tutorial
Understanding Floating Point Numbers
Remote Procedure Calls
Graphics Programming
OpenGL Tutorial
3D Rotations Tutorial
C/C++ DOS Graphics Tutorial
Artificial Intelligence, Algorithms and Data Structures
AI Tutorials
Basic Data structures (queues, stacks, trees, heaps)
Big-O notation, Sorting and Searching
Advanced Algorithms: compression, encryption, graph algorithms, and dynamic programming
The limits of computation
Miscellaneous Articles
Learning to Program in C++
Intro to C++ The basics of C++ (Quiz)
If statements If statements, and some boolean information (Quiz)
Loops in C++ All you want to know about loops (Quiz)
Functions Functions...all about them, making and using the critters (Quiz)
Switch case About the switch case structure (Quiz)
Pointers Using pointers to access memory locations (Quiz)
Structures Structures, all about 'em, and how to use 'em (Quiz)
Arrays All about arrays (Quiz)
Strings About character arrays (strings) (Quiz)
File I/O About file i/o (Quiz)
Typecasting Typecasting: making variables look like another data-type (Quiz)
Classes Introduction to Object Oriented Programming (OOP) (Quiz)
Inline functions More information about functions (Quiz)
Command line arguments How to accept command line arguments (AND checking file existence) (Quiz)
Linked Lists The basics of singly linked lists
Recursion Recursion--a function calling itself
Variable argument lists Functions accepting a variable number of arguments
Binary Trees Introduction to an important abstract data type
Inheritance Inheritance - An Overview
Inheritance continued Inheritance - Syntax and examples
Initialization Lists and Inheritance Initialization lists are necessary for most classes that use inheritance or include objects
C++ Class Design More tips and tricks for class design
Enumerated types Learn to use enumerated types for type-safety and clarity
Formatted Output in C++ using iomanip Learn how to create nicely formatted output in C++
Generating random Numbers Tutorial by RoD on generating random numbers.
Using Modulus Tutorial by RoD on the modulus operator
Templates in C++ Learn how to use templated classes in C++
Templated functions Templates can be used to write generic functions as well as generic classes
Template specialization and partial specialization Learn how to optimize templates by creating specialized instances for certain types
Understanding the C Preprocessor -- Constants, Macros, and other Tricks Learn how to use the C preprocessor[Top]
C TutorialThis tutorial is based on the above tutorial, but uses only standard C language features.
Intro to C The basics of C (Quiz)
If statements If statements, and how to use boolean operators (Quiz)
Loops in C All you want to know about loops (Quiz)
Functions Functions...all about them, making and using the critters (Quiz)
Switch case About the switch case structure (Quiz)
Pointers Using pointers to access memory locations (Quiz)
Structures Learn about grouping multiple variables together under a single name (Quiz)
Arrays Learn about arrays--one variable with many values (Quiz)
C-style Strings About character arrays (strings) (Quiz)
File I/O About file I/O in C
Typecasting Typecasting: making variables look like another data-type (Quiz)
Command line arguments How to accept command line arguments (Quiz)
Linked Lists The basics of singly linked lists
Recursion Recursion--a function calling itself
Variable argument lists Learn to write flexible functions accepting a variable number of arguments
Binary Trees Learn about binary trees, a fundamentally important data structure!
The rest of the above C++ tutorials will be ported soon! [Top]
More Advanced C and C++ Language Features
Removing the Mystery of Function Pointers Function pointers are are powerful tool for C and C++ programmers
References C++ references let you write cleaner, more efficient code
Const Correctness--Why bother? Find out what const-correctness and, more importantly, why it should matter to you
How and When to Use Private Inheritance Understand what private inheritance means and how to use it
Bitwise Operators in C and C++ Learn how to use bitwise operators
When To Use Goto: A Partial Defense of the goto Statement Goto can actually be used quite profitably as a means for handling errors cleanly!
Using Exceptions for Error Handling in C++ What are exceptions, why do we use them, and how can we best take advantage of them?
Using Namespaces in C++ Namespaces are a useful way of maintaining logical divisions in your code and encapsulating functionality
Getting out the static Keyword A multipurpose keywords, static can be used globally, locally, and on class variables, with different meanings in each context
File I/O in C Strict C file I/O and binary file I/O
Templated Classes in C++ Templates in C++
Using auto_ptr to manage memory Learn how to use auto_ptr to help avoid memory leaks
C++ style strings C++ strings can save you a lot of time and frustration when used correctly
The friend keyword and data encapsulation Learn how to use the friend keyword to simplify class interaction while preserving data encapsulation
Secure Coding Learn how to make your programs safe against buffer overflow and double free attacks
Unicode: What you Can Do About it Today Do you have an international audience? Do you need to support multiple multiple languages? Learn to write programs that support Unicode! [Top]
C++ Standard Template Library (STL)
An Introduction to the Standard Template Library (STL) An introduction to and explanation of the Standard Template Library and its features
The STL Vector Container A tutorial on using the vector class
STL Iterators A tutorial covering iterators, an important component of the Standard Template Library for accessing elements of collections
STL Map Container Learn how to use associative arrays in the C++ Standard Template Library to store (key, value) pairs
STL List Container Learn how to use linked lists in the C++ Standard Template Library to store data [Top]
Understanding Floating Point Numbers by Jeff BezansonEvery programmer should understand enough about floating point numbers to avoid the pitfalls of assuming perfect precision.
Background: Accuracy vs. Precision
Floating Point Representation
Bonus: Printing Floating Point Numbers Cleanly [Top]
Using Remote Procedure Calls (RPCs) by Jeff Bezanson
Background and Using the RPC compiler
Writing the Server Code
Writing the Client and Putting it All Together
Get the code [Top]
OpenGL Tutorials(By RoD)
Intro to OpenGL
OpenGL vs DirectX Comparison of OpenGL and DirectX
OpenGL and Windows Intro to Windows Programming for OpenGL
The WinMain procedure More Windows Programming background
Windows Programming The guts of Windows Applications
Intro to WGL Intro to Windows Graphics Layer
Getting started with OpenGL The first OpenGL program
Projections Using Projects in OpenGL[Top]
Rotations in Three Dimensions by Confuted and SilvercordThis is a series of tutorials detailing the math required for performing three dimensional rotations.
The Basics of 3D rotations
Rotation Matrices
Rotation about an Arbitrary Axis
Uses for what you've learned
Using Quaternions[Top]
Graphics Programming TutorialsI offer these tutorials more as a relic of programming lore than a serious study in how to program graphics today; nonetheless, if you are searching for C/C++ DOS graphics, these tutorials may be helpful. They are written by Grant Smith, aka Denthor of Asphyxia. You can find the source code mentioned in the tutorials here.
The MCGA mode and how you get into it in C++ without a BGI
What is the Pallette?
Circle and line algorithms
What is a Virtual Screen and why do we need it?
What is scrolling?
Why do I need a lookup table? What is it?
The Principals of Animation
Optimisation
3D System[Top]
AI Tutorials
Perceptrons Learn about a simple way to simulate neurons
MiniMax Game Trees Learn about coding a decision-making program
Chess Board Representation Learn about efficient chess board representations
Solving problems with genetic algorithms An overview of how genetic algorithms work, and how they've been used.[Top]
Data Structures
Stacks Learn what a stack is and when it might be used
The Queue Read about what a queue is and how to implement it
Heaps Learn what a heap is, why, when and how to use heaps
Graphs in computer science Learn the difference between directed and undirected graphs and why they're useful
Two-three trees Learn about a data structured that helps with balancing the search tree[Top]
Algorithmic Efficiency and Sorting and Searching Algorithms
Algorithmic Efficiency and Big-O notation How to determine the efficiency of your program and understand common algorithms
Efficiency, Time and Space Learn how time and space are balanced in the design of algorithms
Search Algorithms Covers various techniques for search algorithms, from linear search to advanced versions of binary search
Comparison of Sorting Algorithms See how the various sorting algorithms compare (and how to compare them) and pick which ones to use
Intro to sorting algorithms: bubble sort Learn about sorting algorithms, bubble sort, and how it compares to other sorting methods
Selection sort and Insertion sort Two sorting algorithms usually superior to bubble sort
Heap Sort A sorting algorithm based on heaps that runs in O(nlog(n)) time.
Merge Sort A stable sort running in O(nlog(n)) time, generally faster than heap sort, but requiring scratch space.
Quicksort [By Jakub Bomba (axon)] Quicksort is the fastest sort in the average case, requires no additional space, and is stable
Radix Sort Learn about radix sort, a special case sorting algorithm for certain inputs [Top]
Advanced Algorithms
Exclusive-OR (XOR) Encryption A tutorial on Exclusive-OR encryption.
Dijkstra's Algorithm Learn how to find single-source shortest paths on graphs
Dynamic Programming with Examples from Graph Algorithms Learn how to use dynamic programming to solve interesting problems including the all-pairs shortest path problem.
Minimum Spanning Trees and Prim's Algorithm What is a minimum spanning tree, why we care, and how to compute them
Huffman Encoding Learn how to compress data using the Huffman encoding algorithm [Top]
Computer Science Theory
An introduction to the topic of computer science Learn a bit about the history and goals of computer science
Base Systems - Binary, Hex and Octal Find out how binary, hexadecimal and other bases work
The Halting Problem Not for the faint of heart (or beginners), this tutorial covers an advanced topic in computer science: the nature of what can and cannot be computed -- what types of problems computers simply cannot solve
What We Cannot Know: Consequences of the Halting Problem Learn how the theory behind the halting problem can be applied to questions about what we cannot compute [Top]
Programming Articles
Test Driven Development, The Philosophy Learn about why writing tests first makes sense and how to use unit tests
Where C and C++ Differ If you're moving from C to C++ (or vice-versa), watch ouf for these gotchas
Java for C++ Programmers: A Syntax Cheat Sheet A cheat sheet providing a list of numerous small differences between Java and C++.
So you want write a game? Find out what goes into writing a game!
How do you tell how large an object is? Find out how to determine the size of a class object
Programming Style, Part 1: Whitespace Improve your coding style and understand why whitespace matters
Programming Style, Part 2: Naming Conventions Improve your coding style and understand how to choose good names and what traps to avoid
Programming Style, Part 3: How you can write readable code, and why you should
unravelling the mysteries of makefiles Learn how make works and how to write a makefile
advanced makefile tricks Learn how to write more sophisticated make files
Dealing with the compilation process Learn how to handle compiler warnings and errors
Why you should fix compiler warnings Learn why compiler warnings matter, and what some of them mean
How to Start Writing a Program Tips on how to avoid getting lost when writing a large program
Module Development for Game Design Learn some tips and tricks for developing a module system for games
Debugging binary search: the difficulty of getting your code right the first time The story of a small bet between friends -- can Joe write a perfect binary search function without testing?
New Year's Resolutions for C/C++ Programmers A few fun resolutions for you to keep this year, of just suggestsions of ways to spend some time
How -- and Why -- to Comment Why commenting makes you a better programmer
Thinking about Programming A Guide to Program Design for beginners
Common Coding Mistakes An overview of commonly made programming mistakes.
A Summary of C# A discussion of the C# programming language, Microsoft's language based on language principles from C and C++
A Programming Language Comparison Learn more about the different types of programming languages available!

C++ BOOK


This page contains information concerning a draft version of a book "A Beginners' C++"; this book is intended for "CS1, CS2" introductory Computer Science courses that use C++ as an implementation language.
Note: this text was completed in 1996. C++ has been revised quite a bit since then! When the examples were written, C++'s "namespace" feature had been defined but was not supported on available compilers; so the examples don't use namespace. (Of course, in modern C++ they should.)Further, the iostream library has been updated. Some of the functions have changed their signatures; some features have been added, others removed.So, be cautious with the code - it is well a little out of date.
A Beginners C++The table of contents given below includes links to additional materials. Some complete chapters, and various subsections, are available either as Postscript files or directly readable "html" text. There are also links to a couple of files with example code. The code should be usable with the Borland development environment for the PC, or Symantec-8 for the Macintosh.
To save space and transmission time, many of the Postscript files have been compressed. The files were compressed using gzip on Unix. You have to uncompress them (gunzip) before viewing them with ghostview or sending to a printer. (If you go to Javaworld you will usually find that they have dowloadable copies of gzip utilities for both Mac and PC available on their page. The links are at the bottom after their stories about Java developments.) (If you need a viewer for postscript, try: University Wisconsin, ghostscript, ghostview, gs page )
The postscript files have been "distilled" into Adobe PDF files. This makes them smaller, and so easier to download; it should also make them easier to read on a variety of systems.
Preface(PDF of table of contents)
Part 1 Introduction to Computers
Computer Hardware(Postscript file of Computer Hardware Chapter)
CPU and instructions
Memory and Data
Bus
Peripherals
Disks and tapes
Other I/O devices(PDF of chapter 1)
Programs: Instructions in the Computer(PDF of chapter)
Programming with bits!
Loaders
Assemblers
Coding in assembly language
From Assembly Language to "High Level" languages
Operating Systems(Postscript file of Operating Systems chapter)
Origins of "Operating Systems"
Development of Operating Systems: Multiprogramming* Timesharing* File Management* Virtual Memory* "Spooling"* Late 1960s early 1970s system* Networking*
Modern systems: UNIX* Macintosh OS*(PDF of chapter)
Why have "high-level" languages? (Postscript file of chapter)
Limitations of Assembly Language and Origins of High Level Languages
High level languages constructs: Statements* Data types and structures*
Evolution of high level languages
FORTRAN
BASIC
Lisp
COBOL
ALGOL
The "Algol Family":AlgolW, Pascal, and Modula2* ADA* BCPL, C, and C++* Simula, SmallTalk, and Eiffel*(PDF of chapter)
C++ development environment(Postscript file of chapter)
Integrated Development Environment
C++ input and output
A simple example program in C++:Design* Implementation*(PDF of chapter)
Part 2 Simple Programs
Sequence (PDF of chapter)
Overall structure and main() Function
Comments
Variable definitions
Statements
Examples: "Exchange rates"* pH*
Naming rules for variables
Constants
Initialization of Variables
Converting data values
Iteration (PDF of chapter)
While loops
Examples: Modelling the decay of CFC gases* Newton's method for finding a square root* Tabulating function values*
Blocks
"Boolean" variables and expressions True and False* Expressions using "AND"s and "OR"s*
Short forms: C/C++ abbreviations
Do ... while
For loop
Break and Continue statements
Selection (PDF of chapter)
Making choices
A realistic program: Desk Calculator
IF...
Terminating a program
Example Programs: Calculating some simple statistics* Newton's method for roots of polynomials*
What is the Largest? What is the Smallest?
Simple use of files
Dealing with more data
Defining filestream objects
Using input and output filestreams
Stream states
Options when opening filestreams
When to stop reading data?
More Formatting options
Example(html text of most of section on files) (PDF of chapter)
Part 3 Functions and Data Aggregates
Functions (PDF of chapter)
Form of a function Definition
Result types
Function declarations
Default argument values
Type safe linkage, Overloading, and Name Mangling
How functions work
Inline functions
A recursive function
Examples of simple functions: GetIntegerInRange* Newton's square root algorithm as a function*
The rand() function
Examples: pi-Canon* (html text of section introducing coding example), (text file with all code for pi-cannon) Function plotter*
Arrays (Postscript file of chapter)
Defining one dimensional arrays
Initializing one dimensional arrays
Simple Examples Using One-Dimensional arrays: Histogram* Plotting once more*
Arrays as arguments to functions
Strings: Arrays of characters
Multi-dimensional arrays: Definition and initialization* Accessing individual elements* As arguments to functions*
Arrays of Fixed length Strings
Examples using arrays: Letter Counts* Simple encryption* Simple image processing*(PDF of chapter)
Programs with functions and arrays (postscript file of chapter with several examples using functions and arrays)
Curses
Heat diffusion
Menu Selection
Pick the keyword
Hangman (html text of section introducing hangman problem), (text file with all hangman code)
Life(PDF of chapter)
Standard algorithms(Postscript text of chapter on standard searching and sorting functions)
Finding the Right Element: Binary Search: An iterative binary search routine* Isn't it a recursive problem?* What was the cost?
Establishing Order
A simple sort of sort
Quicksort: a better sort of sort: The algorithm* An implementation* An enhanced implementation* (html text of section on Quicksort) (PDF of chapter)
Algorithms, Functions, and Subroutine Libraries
Tools (html text chapter on support tools for program development),
The "Code Coverage" Tool
The Profiler(PDF of chapter)
Design and documentation : 1
Top down functional decomposition
Documenting a design(PDF of chapter) (PDF of coding guidelines)
Enum, Struct, and Union
Enumerated types
structs
Unions(html text of section on C/C++ Unions)(PDF of chapter)
Examples using structs
Reordering the class list again
Points and Rectangles
File of Records(PDF for chapter)
Bits and pieces(Postscript file for chapter explaining role of bit-level operations in C/C++)
Bit manipulations
Making a Hash of it: Example hashing function for a character string* A simple "hash table"* Example: identifying the commonly used words*
Coding "Property Vectors"
Pieces (Bit fields) (PDF of chapter)
Part 4 A Touch of Class
Beginners' Class
Class declarations and definitions: Form of a class declaration* Defining the member functions* Using class instances* Initialization and "constructor" functions* const member functions* inline member functions*
Example: Bitmaps (Sets)
Numbers - a more complex form of data (details of a class for +, -, *, /, on 100 digit numbers; as a postscript file) code of multidigit arithmetic class
A glance at the "iostream" classes(PDF of chapter)
Dynamic data and pointers (Postscript file of chapter)
The "Heap"
Pointers: Some "pointer" basics* Using pointers* Strings and hash tables revisited*
Example: "Air Traffic Controller"
The "address of" operator
Pointers and Arrays
Building Networks(PDF of chapter)
Collections of data (postscript file of chapter presenting several standard "collection class" abstract types)
Class Queue
Class PriorityQueue
Class DynamicArray (code in C29 and C30 examples)
Class List
Class BinaryTree (code in C23 iterators example)
Collection class Libraries(PDF of chapter)
A World of Interacting Objects
RefCards: Design* Implementation*
InfoStore: Initial design outline for InfoStore* Design and Implementation of the Vocabulary class* Other classes in the InfoStore program* Final class design for the InfoStore program(Postscript file, long case studies suggesting how to identify and then characterize objects and their classes (PDF of chapter)
Intermediate class
Shared Class Properties
Friends
Iterators: ListIterator* TreeIterator*(html file on Iterators for collection classes), (example code with tree iterator)
Operator functions: Defining operator functions* Operator functions and the iostream library*
Resource Manager Classes and Destructors: Resource management* Destructor functions* The assignment operator and copy constructors*
Inheritance: Discovering similarities among prototype classes* Defining Class Hierarchies in C++* But how does it work?!* Multiple Inheritance* Using Inheritance (html file of section introducing inheritance and C++ class hierarchies)(PDF of chapter)
Two more "trees"(Postscript file of chapter on AVL trees and Btree storage structures)
AVL Trees: What's wrong with binary trees?* Keeping your balance* An implementation* Testing!*(code for an AVL tree class)
BTree: Multiway trees* A tree on a disk?* BTree: search, insertion, and deletion operations* An implementation* Testing* (code in C30 example)(PDF of chapter)
Templates (Postscript file of Templates chapter)
A general function and its specializations
Language Extensions for Templates:Template declaration* Template instantiation*
Specialized Instantiations of Template Code
A Template Version of QuickSort
The Template Class "Bounded Array"
The Template Class Queue(PDF of chapter)
Exceptions (Postscript file of Exceptions chapter)
C++'s Exception Mechanism
Example: Exceptions for class Number
Identifying the Exceptions that you intend to throw(PDF of chapter)
Example: Supermarket
Background and Program Specification/li>
Design: Design preliminaries* Scenarios: identifying objects, their classes, their responsibilities, their data* Filling out the definitions of the classes for a partial implementation*
A partial implementation
Finalising the Design: Histograms* Simulating the checkouts and their queues* Organizing the checkouts*(PDF of chapter)
Design and documentation: 2
Object-Based Design
Documenting a design(PDF of chapter)
Part 5 Object Oriented Programming (Paper describing approach to teaching OO)
The Power of Inheritance and Polymorphism (postscript file, of chapter with example illustrating use of inheritance and polymorphism)
The "Dungeon" Game
Design: Preliminaries* WindowRep and Window classes* DungeonItem hierarchy*(html text of chapter with example illustraing inheritance)
An implementation: Windows classes* Class Dungeon* DungeonItems*( html text of chapter with example illustraing inheritance), (the code for "dungeon game" example)(PDF of chapter)
Reusable designs
The RecordFile Framework: Concepts(html text)
The Framework classes: Overview
The Command Handler Classes: Class declarations* Interactions* Implementation Code*
Collection Classes and their Adapters*
Class Record
The Windows Class Hierarchy: Class Responsibilities* Implementation Code* Using the concrete classes from a framework*
Organizational Details(Student Rec application, example use of a framework) (code for a simplified framework class library and application) (PDF of chapter)
Frameworks for understanding(Postscript file introducing standard framework class libraries)
"Resources" and "Macros"
Architects, Experts, and Wizards
Graphics
Persistent Data
The Event Handlers
The Same Patterns in the code(PDF of chapter) (page index) (Another document on use of frameworks.) (Postscript introduction to frameworks like ET++ and MacApp)
Java? Some teaching materials from an introductory course on Java and the Internet for those who have a little background in C++. CSCI213: Java and the Internet
Please email questions to nabg@cs.uow.edu.au