Instructor-led training
C++ Programming for C Programmers
This course is a comprehensive hands-on introduction to object oriented programming in C++ for C programmers.
What you'll learn
Private Training for Teams
This course is offered as private, instructor-led training for organizations. Dates, delivery format, and course content are arranged around your team's requirements.
This course is not currently scheduled as a public class for individual enrollment.
Request Group TrainingPrerequisites
Course Outline
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 and 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 Initialization
Constructors and Initialization
Constructor in Stack Class
Object Creation and 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, Initialization, 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
Test Program
Scope and Access Control
Scoping in C++
Block and Function Scope
File and Global Scope
Class Scope
Constant Types and 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++
Employee Test Program
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
ANSI C++ Library
ANSI C++ Library
Hello ANSI C++
Namespaces
ANSI C++ String Class
Templates
Templates
General Purpose Functions
Macros
Function Templates
Template Parameters
Template Parameter Conversion
Generic Programming
General Purpose Classes
Class Templates
Array Class Implementation (array.h)
Using the Array Template
Template Parameters
Class Template Instantiation
Non Type Parameter Conversion
Standard Template Library
STL Components
STL Elements of a Simple Program
Simple STL Program
Map Container
Input/Output in C++
Input/Output in C++
Built-in Stream Objects
Output Operator <<
Input Operator >>
Character Input
String Input
Formatted I/O
Streams Hierarchy (Simplified)
File I/O
File Opening
Integer File Copy
Character File Copy
Overloading Stream Operators
Implementing Overloaded Stream Operators
Practical Aspects of C++ Programming
Interfacing C++ to Other Languages
Calling C from C++
_cplusplus Macro
Calling C++ from C
Interface Module for Stack Class
Namespace Collisions
ANSI Namespace
Reliability Philosophies of Languages
Prototypes and Type Checking
Constant Types
Access Control in C++
Reviews and Inspections
Inspections and C++
Testing Strategies for C++
Performance Considerations
Class Libraries
Exception Handling
Exception Handling
try and catch
Exception Flow of Control
Context and Stack Unwinding
Handling Exception in Best Context
Benefits of Exception Handling
Unhandled Exceptions
Clean Up
Multiple Catch Handlers
Runtime Type Information
Runtime Type and Polymorphism
type_info Class
typeid Operator
Compiler Options
Safe Pointer Conversions
Dynamic Cast
New C++ Style Casts
Static Cast
Reinterpret Cast
Const Cast
What makes this material hard to master
A C programmer already knows pointers, structs and manual memory. The difficulty here is that C++ attaches behavior to those same ideas, so familiar code can start doing things you did not write. The syllabus builds in a deliberate order.
- Classes first. It starts with encapsulation in C, then the C++ class, the
thispointer, scope resolution and abstract data types. Function topics follow: strong type checking, inline functions, default arguments, and overloading with argument matching by promotion and by conversion. - Object lifetime. Constructors, destructors,
newversusmalloc,deleteand free store allocation come next. The course develops a String class through several versions and examines the bugs in each. Those bugs lead to the copy constructor, the default copy constructor, the assignment bug and overloading=. Many developers assume the compiler-generated copy is safe for a class that owns memory, and this sequence shows why it is not. - Const and references. Call-by-reference,
constobjects andconstmember functions, returning a temporary versus returning a reference, and conversion by construction or by cast operator. - Inheritance and dispatch. Protected members, member initializer lists, order of initialization, inheritance versus composition, dynamic binding, the vtable, virtual destructors, pure virtual functions and heterogeneous collections. Forgetting a virtual destructor is a classic error here.
- Second module. Namespaces, the ANSI C++ string class, function and class templates, an introduction to the STL (including the map container), I/O streams, exception handling with stack unwinding, RTTI,
dynamic_castand the C++ style casts.
Who it suits and what to take around it
The course suits developers with a good working knowledge of C who need to read, maintain or extend C++ code, or move a C codebase toward classes and reuse. Training managers can treat it as a five-day, general-level course for C teams. Developers without C experience will usually be better served by C++ Programming for Non-C Programmers, which starts from a different baseline.
After this course, Advanced C++ Programming is the natural step for deeper design work. The syllabus here only introduces the STL, so a team that wants to build on templates and containers can continue with Modern C++ Programming using C++11/C++14. Organizations whose compilers or standards differ from what is covered here can ask for a private course tailored to the versions they use.
Illustrative scenarios
The scenarios below are illustrations of how the course material can be applied. They are not descriptions of specific organizations or of the course's lab exercises.
- Wrapping a C library. A team might have a working C stack or data module and want C++ callers to use it safely. The syllabus topics on calling C from C++, the
_cplusplusmacro, calling C++ from C, an interface module for a Stack class and namespace collisions map directly to that job. - A class hierarchy for varied records. A team modeling different kinds of employees or devices might keep them in one collection and process each through a common interface. That relies on inheritance, abstract classes with pure virtual functions, virtual destructors and heterogeneous collections. Choosing between inheritance and composition is part of the same decision.
- File processing with error handling. A team reading and writing records might overload the stream operators for its own types and use file I/O. It could then add
try/catchhandling, so that clean-up still happens when an error unwinds the stack.
AI coding assistants and these topics
AI coding assistants can explain unfamiliar class code, draft test programs for a class, and suggest what a compiler diagnostic means. They are useful for the first draft of an overloaded operator or a template. They are also unreliable in the areas this course concentrates on.
- Ownership. Generated classes that hold
new-allocated memory often omit a correct copy constructor, assignment operator or destructor. That is the same bug the String class exercise exposes. - Inheritance. Assistants may leave out a virtual destructor on a base class or slice objects when passing them by value.
- Casts and exceptions. Code may use
reinterpret_castorconst_castwherestatic_castordynamic_castis the safe choice. Catch handlers may be ordered wrongly, or clean-up may be missing on the exception path.
To verify, write a test program that copies, assigns and destroys each object, and run it under a memory checker. Compile with warnings enabled and review every cast and every delete by hand. Knowing the syllabus material is what lets you tell correct generated code from code that only compiles.
Frequently asked questions
What level is this course and what do I need beforehand?
It is a general-level, five-day course. You need a good working knowledge of C programming. No prior C++ or object-oriented experience is assumed, since the course begins with object-oriented concepts.
What does the course cover?
Module one covers classes, constructors and destructors, memory management, references, operator overloading, scope and access control, inheritance and virtual functions. Module two covers the ANSI C++ library and namespaces, templates and an introduction to the STL, I/O streams, interfacing with C, exceptions, RTTI and the C++ style casts.
Can the course be delivered privately for our team?
Yes. HSG delivers private training for organizations, either onsite at the client's location or live online.
Can the content be customized?
Private courses can be customized, including tailoring to the compiler and language versions your team uses. You can describe your needs through the training proposal request.Training locations
C++ Programming for C Programmers training across the U.S. and beyond.
We provide private C++ Programming for C Programmers training for organizations, onsite at your location or live online, throughout the United States and internationally.
- Denver
- Atlanta
- Phoenix
- Boston
- Sacramento
- Austin
- Salt Lake City
- Raleigh
- Columbus
- Nashville
- Indianapolis
- Richmond
- and more
View all C++ Programming for C Programmers training locations
- Denver, Colorado
- Montgomery, Alabama
- Little Rock, Arkansas
- Atlanta, Georgia
- Juneau, Alaska
- Indianapolis, Indiana
- Honolulu, Hawaii
- Trenton, New Jersey
- Springfield, Illinois
- Providence, Rhode Island
- Boston, Massachusetts
- Phoenix, Arizona
- Sacramento, California
- Dover, Delaware
- Tallahassee, Florida
- Boise, Idaho
- Richmond, Virginia
- Des Moines, Iowa
- Topeka, Kansas
- Frankfort, Kentucky
- Baton Rouge, Louisiana
- Augusta, Maine
- Annapolis, Maryland
- Lansing, Michigan
- Saint Paul, Minnesota
- Jackson, Mississippi
- Jefferson City, Missouri
- Helena, Montana
- Lincoln, Nebraska
- Carson City, Nevada
- Concord, New Hampshire
- Santa Fe, New Mexico
- Albany, New York
- Raleigh, North Carolina
- Bismarck, North Dakota
- Columbus, Ohio
- Oklahoma City, Oklahoma
- Salem, Oregon
- Harrisburg, Pennsylvania
- Columbia, South Carolina
- Pierre, South Dakota
- Nashville, Tennessee
- Austin, Texas
- Salt Lake City, Utah
- Montpelier, Vermont
- Olympia, Washington
- Charleston, West Virginia
- Madison, Wisconsin
- Cheyenne, Wyoming
- Hartford, Connecticut
- Toronto, Canada
- Berlin, Germany
- Stockholm, Sweden
- London, United Kingdom
- Dublin, Ireland
Train your team with HSG
Private, instructor-led training customized for your organization.
- Onsite or live online delivery
- Customized curriculum
- For a single employee or an entire team
- Flexible scheduling
- Experienced instructors
Questions? Call us at 303.377.6176
or email info@hartmannsoftware.com
Ready to train your team?
Let's customize this training for your organization.
Tell us about your employees, your goals, and your preferred schedule. We'll prepare a training proposal covering scope, delivery format, and pricing.