Duration: 5 Days
Description
This course is a comprehensive hands-on introduction to object-oriented programming in C++ for 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 16 modules. Extensive programming examples and exercises are provided. The course is designed so that it can be taught in any environment with an ANSI C++ compiler.
Audience
This course is designed for experienced C programmers who want to expand their knowledge into C++ and object-oriented programming. It is ideal for developers looking to leverage C++ features such as classes, inheritance, polymorphism, templates, and exception handling to build more robust and maintainable software. Participants should already be comfortable with procedural programming and fundamental programming concepts in C. The course assumes a strong grasp of C syntax and memory management, allowing learners to focus on the unique and advanced features C++ introduces.
Objectives
- Learn object-oriented concepts
- Acquire a thorough working knowledge of C++ programming
- Gain an understanding of the issues involved in effective class design
- Learn how to program with templates and become introduced to STL
- Become introduced to newer features of C++, including the ANSI standard library, exception handling, and RTTI
Prerequisites
This course assumes a good knowledge of C programming. Students without a strong background in C should consider instead the course C++ Programming for Non-C Programmers.
Course Outline
Module 1: Concepts of Object-Oriented Programming
- Objects
- Information Hiding and Encapsulation
- Abstract Data Types
- Methods and Messages
- Classes
- Class Inheritance
- Polymorphism
Module 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
Module 3: Functions in C++
- Function Prototypes and Type Checking
- Conversion of Parameters
- Default Arguments
- Inline Functions Function Overloading
Module 4: Constructors and Destructors
- Constructors and Initializations
- Object Creation and Destruction
- Destructors
- Multiple Constructors in a Class
- Hidden Constructors
Module 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
Module 6: References and Argument Passing in C++
- Call by Value
- Reference Declarations
- Reference Arguments
- Copy Constructor
- Constant Arguments and Functions
Module 7: Operator Overloading, Initialization, and Assignment
- Operator Overloading
- Semantics of Assignment
- Initialization vs. Assignment
- Overloading Assignment
- Type Conversions
Module 8: Scope and Access Control
- Scope in C++
- Friend Functions
- Const and Enumeration Types
- Static Members
Module 9: Introduction to Inheritance
- Inheritance for Modeling and Reuse
- Class Derivation
- Access Control
- Base Class Initialization
- Composition
- Initializing Class Type Members
Module 10: Polymorphism and Virtual Functions
- Virtual Functions and Dynamic Binding
- Polymorphism in C++
- Pointer Conversion
- Virtual Destructors
- Abstract Classes and Pure Virtual Functions
Module 11: ANSI C++ Library
- New Header Files
- Namespaces in the Standard Library
- ANSI C++ String Classes
- Templates in the Standard Library
Module 12: Templates
- C++ Template Mechanism
- Function Templates
- Class Templates
- Generic Programming
- Implementing a General Array Class
- Standard Template Library
Module 13: Input/Output in C++
- Streams I/O Library
- Formatted Stream I/O
- File I/O
- I/O in User Defined Classes
Module 14: Practical Aspects of C++ Programming
- Interfacing C and C++
- Namespaces
- Reliability in C++ Programs
- Testing Considerations
- Efficiency Considerations
Module 15: Exceptions
- C++ Exception Mechanism
- Exceptions Compared to Other Error Handling Techniques
- throw, try, and catch
- Exception Context and Stack Unwinding
- Uncaught Exceptions
- Automatic Cleanup in Exception Handling
Module 16: Runtime Type Information
- Runtime Type Information (RTTI) Mechanism
- type_info Class and typeid Operator
- Type Safe Pointer Conversion
- New C++ Cast Syntax