Programming in C++
Course objectives
After completing this course you will be able to:
- use flow control statements
- create functions and modules
- apply the principles of object-oriented programming in C++
- securely manage memory with smart pointers
- create classes and objects
- use inheritance and polymorphism
- use streams
Course syllabus
Introduction to C++
- The basic anatomy of a C++ program
- The compilation process and linking
- Preprocessor
- Data types, operators, and control statements
- Creating variables and constants
- The scope of a variable
- Auto type deduction
- Type conversion
- Pointers and references
Functions and modules
- Function declaration syntax
- Passing parameters to functions
- Header files and source files
#include
barriers- Namespaces
Pointers and arrays
- Arrays in C++ - native arrays and
std::array<T>
- Iterating over the range – pointers, iterators, range-based-for
- Strings – c-strings and
std::string
- Basic STL containers
std::vector<T>
std::list<T>
std::map<K, T>
andstd::unordered_map<K, T>
Object oriented programming in C++
- User types - classes and structures
- Member functions - methods
- Constructors
- Resource management - RAII
- Destructors
- Special copy functions
- Move semantics
- Overloading operators
- Memory management – smart pointers
std::unique_ptr
std::shared_ptr
Function objects and lambda expressions
- Callable objects in C++11
- Function objects
- Lambda expressions
std::function
– callbacks in C++11- Using lambdas with STL algorithms
Inheritance and polymorphism
- Derived classes
- Constructors and inheritance
- Base class members
- Overloading and overriding
- Types of inheritance – public, protected, private
- Static binding vs. dynamic binding
- Pure virtual functions
- Virtual destructors
- Abstract classes
- Polymorphism in C++
- Example of polymorphism
Multiple inheritance
- Multiple inheritance example
- Problems with multiple inheritance
- Virtual base class
Exception handling
- Handling errors
try... catch
block- Standard exception classes
- User-defined exception classes
Streams
- iostream library
std::cin
,std::cout
andstd::err
streams- File streams
Prerequisites
Experience in another language (e.g. C, Pascal, Java, Python).