C++ is a remarkably powerful systems-programming language, combining multiple programming paradigms – Procedural, Object Oriented and Generic – with a small, highly-efficient run-time environment. This makes it a strong candidate for building complex high-performance embedded systems.
The C++11 standard marked a fundamental change to the C++ language, introducing new idioms and more effective ways to build systems. This new style of programming is referred to as ‘Modern C++’.
This practical, hands-on course introduces the C++ language for use on resource-constrained, real-time embedded applications.
The course highlights areas of concern for real-time and embedded development. The focus is on developing effective, maintainable and efficient C++ programs.
A five-day course that provides a practical overview of C++ focusing on developing object-oriented programs in an embedded, real-time environment.
- To provide a solid understanding of the essentials of the C++ programming language.
- To give you practical experience of writing Modern C++ for resource-constrained real-time and embedded systems.
- To give you the confidence to apply these new concepts to your next project.
Delegates will learn:
- Modern C++ syntax and semantics and idioms
- Using C++ for hardware manipulation
- The Application Binary Interface (ABI) and memory model of C++
- Idioms and patterns for building effective C++ programs
- A strong working knowledge of C
- Embedded development skills are useful, but not essential
Who should attend:
This course is aimed at C programmers who are moving to C++ for their embedded development.
- Five days
- Delegate manual
- Delegate workbook
- Delegate datakey
Attendees perform hands-on embedded programming, on target hardware, during course practicals. Approximately 50% of the course is given over to practical work.
The board targeted is an ARM Cortex-M based MCU which gives attendees a real sense of embedded application development.
- "Hello World!"
- The build process
- Object files
- Linking Activities
- C++ stream I/O objects
- Stream modifiers
The C++ object model
- Objects and types
- Brace initialisation
- Object visibility scope
- Object lifetime
- Compile-time constant expressions
- Enum classes
- Dynamic objects
- The value of an ‘empty’ pointer
- Pointers and const
- Memory-mapped registers are accessed via pointers
- volatile objects
- Bitwise Operators
- General Purpose Input / Output (GPIO)
- User-defined types
- Performance implications of packing
- The iterator model
- Range-for statement
- Applying algorithms to arrays – filling and sorting
- The 'One Declaration Rule'
- How function arguments are passed
- The overheads of pass-by-value
- std::tuple represents a general n-tuple
- Function overloading
- Function inlining
- Separating Interface and Implementation
- Compilation Dependencies
- Using the __cplusplus macro
- Defining functions within a namespace
- Ambiguity when accessing namespace members
Principles of Object Oriented Design
- The Single Responsibility Principle
- Creating new types
- Access specifiers
- 'this' pointer
- Non-Static Data Member Initializers (NSDMIs)
- The compiler-supplied default constructor
- The class destructor
Objects and functions
- Explicit constructors
- Disabling pass-by-value
- Disabling copying
- Return Value Optimisation (RVO)
- 'Copy elision'
- The static storage specifier
- Static member variables
- Static member functions
- An Object-Oriented approach to I/O
- Using a struct for I/O device access
- Nesting a structure overlay in a class
- Problem domain types
- Overloading the stream operator
- Conversions to other user-defined types
Building composite objects
- Composite aggregation
- Overriding default initialisers
- The composite object on the stack...
- Connected objects form a system
- Forming the Association (Client-Server)
- Bi-directional associations…
- Friend functions
- Forward references to namespace elements
Creating Substitutable Objects
- Overriding base class behaviour
- The 'protected interface'
- The Liskov Substitution Principle
- Late binding (of polymorphic operations)
- Dynamic binding
Abstract Base Classes
- An abstract class
- Extending derived classes
- Safely accessing the extended interface
- The Dependency Inversion Principle
- Provided and Required Interfaces
- The Interface Segregation Principle
- Memory model
- std::unique_ptr allows single ownership
- std::shared_ptr is reference-counted
- Resolving circular dependency issues
- Sequence containers
- std::vector is a dynamically-resizable array
- std::list is a doubly-linked list
- Key-value containers – std::pair
- Sorted containers
- Containers and memory allocation
- Function objects
- Under the hood
- Using std::function for call-back
- Containers of callable objects
- initializer_list overload rules
- Generic programming
- Function templates
- Overloading with template functions
- Class templates
- Lazy instantiation
- Member Functions of Class Templates