153. C++ Programming for
Non-C Programmers
Rev. 8.0
This course is a comprehensive hands-on introduction to object
oriented programming in C++ for non-C programmers. Emphasis is placed on the
features of C++ that support effective modeling 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. The
course is current to ANSI standard C++ and is designed so that it can be taught
in any environment with an ANSI C++ compiler.
LEARNING OBJECTIVES
·
Learn the core C features of C++
·
Become acquainted with the basic concepts of
object oriented programming
·
Acquire an introductory knowledge of C++
programming
Course Duration: 5
days
Prerequisites:
Knowledge of a programming language.
Module 1. Introduction to C and C++
1.
First C++ Programs
Hello, World
Program Structure
Output in C++
Variables and Expressions
Calculations Using C++
Input in C++
2.
Data Types and Operators
Strong Typing
Integer Data Types
Floating Point
Conversions Between Types
Arithmetic Operators
Doing Math in C++
3.
Logical and Bit Operations
Bool
Logical and Relational Operators
If Tests
Bitwise Operators
Shifting and Masking
4.
Loops and Structured Programming
While Loops
Quitting Infinite Loops
Curly Braces and Indenting
Sentinels and Counters
For Loops
Loops and If Tests Together
Nested If Statements
Structured Programming
5.
Functions and Program Structure
Function Prototypes and Type Checking
Returning Value and Argument Passing
Pass-by-Reference
External Variables
Block Structure
Scope
Header Files
Preprocessor
6.
Pointers and Arrays
Pointers and Addresses
Pointers and Function Arguments
Address Arithmetic
Pointers and Arrays
Arrays of Pointers
Command Line Arguments
Pointers to Functions
Strings
7.
Structures and Unions
Structures
Structures and Functions
Arrays of Structures
Unions
Module 2. Object-Oriented C++ Programming Fundamentals
1.
Concepts of Object Oriented Programming
Objects
Information Hiding and Encapsulation
Abstract Data Types
Methods and Messages
Classes
Class Inheritance
Polymorphism
2.
Classes in C++
Data Encapsulation in C and C++
Definition of C++ Classes
Member Data and Functions
this Pointer
Abstract Data Types
Organizing Code for Classes
3.
Functions in C++
Function Prototypes and Type Checking
Conversion of Parameters
Default Arguments
Inline Functions
Function Overloading
4.
Constructors and Destructors
Constructors and Initializations
Object Creation and Destruction
Destructors
Multiple Constructors in a Class
Hidden Constructors
5.
Memory Management in C++
Static, Automatic and Heap Memory
New and Delete
Handling Memory Allocation Errors
Hiding Details of Memory Management in a Class
Implementing a Dynamic String Class
6.
References and Argument Passing in C++
Call by Value
Reference Declarations
Reference Arguments
Copy Constructor
Constant Arguments and Functions
7.
Operator Overloading, Initialization, and
Assignment
Operator Overloading
Semantics of Assignment
Initialization vs. Assignment
Overloading Assignment
Type Conversions
8.
Scope and Access Control
Scope in C++
Friend Functions
Const and Enumeration Types
Static Members
9.
Introduction to Inheritance
Inheritance for Modeling and Reuse
Class Derivation
Access Control
Base Class Initialization
Composition
Initializing Class Type Members
10. Polymorphism
and Virtual Functions
Virtual Functions and Dynamic Binding
Polymorphism in C++
Pointer Conversion
Virtual Destructors
Abstract Classes and Pure Virtual Functions
System Requirements
The course is designed to be delivered in any environment supporting
an ANSI C++ compiler. An optional version of the lab file contains project
files for Visual C++ 2005.