Course Description

This C++ Programming Introduction training course is a comprehensive hands-on introduction to object-oriented programming in C++. Emphasis is placed on the features of C++ that support effective modelling of the problem domain and reuse of code. The course consists of two modules. The first module introduces the core C features of C++, with simplified input/output through iostreams. The module begins with simple hands-on programming using C++ to do input, computation and output. The C++ data types are covered, and simple if tests and loops are covered. C++ program structure is introduced. Pointers, addressing, and arrays are discussed. Structures and unions are covered.

In the second module, object-oriented concepts are introduced. The C++ class construct is introduced and its key features elaborated step-by-step, providing full implementation of abstract data types. C++ memory management is discussed. Function and operator overloading and the use of references are covered. The scope and access control mechanisms of C++ are described. Inheritance is introduced. The use of virtual functions to implement polymorphism is discussed. Extensive programming examples and exercises are provided.

Pre-requisites

Knowledge of a programming language. Specific knowledge of the C language is not a requirement.

Who is this course for?

This course is designed for software developers who are moving to object-oriented programming in C++, with or without prior experience in the C language.

Further Training

After some further on-the-job programming experience with the C language, we recommend students attend our
C++ Programming Advanced training course to gain higher-level skills in the usage of the C++ programming language.

Course content

First C++ Programs
Hello, World
Compiling and Running
C++ Program Components
Another C++ Program (Preview)
I/O in C++
Variables
Expressions
Assignment
Using C++ as a Calculator
Input in C++
Echo Program

Datatypes and Operators

Data Types
Strong Typing
Typing in C++
Conversions in C++
Typing in Visual Basic
Primitive C++ Data Types
Signed and Unsigned
Twos Complement
C++ Integer Type Ranges
Integer Constants
Variables in C++
Const Variables
Preprocessor Macros
Identifiers
Floating Point Numbers
Floating Point Data Types
Calculations
Integer Operations
Increment and Decrement
Precedence of Integer Operations
Floating Point Operations
Mixed Data Types
Automatic Conversion
Cast
Math Library

Logical and Bit Operations

Bool Variables
Bool Operations & Truth Tables
Relational Operators
If Tests
A Pitfall
Bitwise Operators
Bitwise Operator Truth Tables
Short Circuit Evaluation
Shifting
Masking

Loops and Structured Programming

Loops
While Loops
Infinite Loops
Flowcharting a While Loop
Indenting & Curly Braces
Accumulating a Total
Total Using a Sentinel
Counted Loops
Total Using a Counter
For Loops
Total Using a For Loop (Up)
Total Using a For Loop (Down)
Comparing For & While Loops
Variable Scope
Loops and If Tests Together
Nested If Statements
Review of Statements
Compound Statements
Structured Programming
Object-Oriented Programming

Functions and Program Structure

Basics of Functions
Function Prototypes and Type Checking
Returning Value
Argument Passing
Pass-by-Reference
Alternative to Pass-by-Reference
External Variables
Block Structure
Scope Rules
Header Files
Preprocessor Directives
Conditional Compilation
Recursion

Pointers and Arrays

Pointers and Addresses
Pointers and Function Arguments
Pointers and Arrays
Address Arithmetic
Dynamic Memory Management
Using malloc and free
Array of Pointers
Strings
String Functions
Array of Strings
Command Line Arguments
Pointers to Functions

Structures and Unions

Fundamentals of Structures
Structure Declaration
Structures and Functions
typedef
Arrays of Structures
Array of Structures Initialisation
Unions

Concepts of Object-Oriented Programming

Object
State and Behavior
Abstraction
Encapsulation
Class and Instantiation
Abstract Data Types
Methods
Invoking Methods
Messages
Class Inheritance
Polymorphism

Classes in C++

Data Encapsulation in C
The C++ Class
Structures & Class in C++
Implementation of a C++ Class
this Pointer
Code Organization
Scope Resolution Operator
Abstract Data Types
Test Programs for C++ Classes

Functions in C++

Function Prototypes in C++
Strong Type Checking
Conversion of Parameters
Inline Functions
Inline Functions in Header Files
Default Arguments
Function Overloading
Argument Matching
Argument Matching through Promotion
Match through Type Conversion
Call by Value

Constructors and Destructors

The Problem of Initialisation
Constructors and Initialization
Constructor in Stack Class
Object Creation & Destruction
Destructors
Multiple Constructors
String Class Implementation
Hidden Constructors
Using a Default Argument
Memory Management in C++
Why is Memory Management Important in C++?
Choices for an Object’s Memory
Typical Memory Layout
Free Store Allocation
new Operator
Memory Allocation Errors
new vs. malloc
delete Operator
Destructor (Review)
Hiding Memory Management
String Class Specification (Version 2)
String Class Implementation
String Class Bug

References and Argument Passing in C++

Variables
Argument Passing
Call-by-Value
Reference Declarations
Call-by-Reference
Copy Constructor
Default Copy Constructor
Bug in String Class
Specification of String Class
Implementation of String Class
Test Program
Output of Test Program
Review of Constant Types
Constants and Arguments
Chains of Functions Calls
const Objects and Member Functions

Operator Overloading, Initialisation and Assignment

Operator Overloading
Operator Functions
Semantics of return
Returning a Temporary Object
Returning a Reference
Initialization vs. Assignment
Semantics of Assignment
Assignment
Assignment Bug
Overloading =
Review of this Pointer
Type Conversions
Conversion by Construction
Overloading Cast Operator

Scope and Access Control

Scoping in C++
Block and Function Scope
File and Global Scope
Class Scope
Constant Types & Scope
Enumeration Types
Enumeration Types and Class Scope
:: for Global Data
Static Class Members
Initialization of Static Member
Static Function Class Members
Access Control
Friend Functions
Invoking Member and Friend Functions
Implementing a Friend Function
Efficiency and Friend Functions

Introduction to Inheritance

Inheritance Concept
Inheritance in C++
Protected Members
Best Class Initializer List
Composition
Member Initializer List
Order of Initialization
Inheritance vs. Composition

Polymorphism and Virtual Functions

A Case for Polymorphism
Dynamic Binding
Pointer Conversion in Inheritance
Polymorphism Using Dynamic Binding
Virtual Function Specification
Invoking Virtual Functions
Vtable
Virtual Destructors
Abstract Class Using Pure Virtual Function
Employee as an Abstract Class
Heterogeneous Collections