C++ for Embedded

C++ for Embedded Developers

Course Description:

A perfectly designed and custom training which focuses on designing and developing solving software requirement using C++ to enhance the skills required in every day programming challenge. This makes it significantly different from most C++ courses which focus on C++ internals above design principles.

The in-house training is backed up by a comprehensive coverage demonstrating the best practices in C++.

Duration: 4 days

Course Objectives:

  • To teach the C++ internal with proven examples
  • To enable attendees to develop their own practical C++ skills
  • To show how to develop C++ software in a systematic manner

Delegates will learn:

  • How to apply the design principles in application
  • Where C++ designs can be used in the development process
  • The core features provided by C++ for OO development methods

Pre-requisites:

  • At least one year understanding of technical software development methods and basic knowledge of C / C++
  • Delegates must undergo an entry test, and post completion an exit test for basic measurement

Who should attend:

  • Programmers new to the area of Software Design using C++
  • Developers embarking on projects using core C++ based techniques for the first time
  • Professionals looking forward to upgrade the knowledge to next level

Course Materials:

  • Soft references as CD or Online reference

Hardware Environment:

  • Windows XP with Microsoft Visual Studio 2005 / 2008
  • GNU tool chains on Linux Environment

Course Delivery Details:

Day-1

  • Programming Paradigms
  • Procedural Programming
  • Object-Based Programming
  • Object-Oriented Programming
  • OOD

Introduction to C++ specific features (Session-1)

  • Data declaration and scope
  • Functions in C++
  • Inline, default argument
  • Overloading
  • References
  • Namespaces
  • Inbuilt support for object oriented features
  • RTTI
  • Exception handling
  • Templates

The Rationale behind namespaces (Session-2)

  • A Brief Historical Background
  • Large-scale projects are more susceptible to name clashes
  • Properties of Namespaces
  • Fully Qualified Names
  • A using declaration and a using directive
  • Namespaces can be extended
  • Namespace Aliases
  • Koenig Lookup
  • Namespaces in Practice
  • Namespace Utilization Policy in Large-scale projects
  • Namespaces and Version Control
  • Namespaces do not incur additional overhead
  • The interaction of Namespaces with other language features
  • Scope resolution operator should not be used to designate Global names
  • Turning an External function into a file-local function
  • Standard headers names
  • Restrictions on Namespaces
  • Namespace std cannot be modified
  • User-defined new and delete cannot be declared in a Namespace

Classes and Objects (Session-3 & 4)

  • Representing Objects in C++

Object members

  • Constructors
  • Calling an Object’s member function from it constructor
  • Trivial constructors
  • Avoid reduplicating identical pieces of constructors’ code
  • Is A default constructor always necessary?
  • When are default constructors’ undesirable?
  • Constructors of fundamental types
  • Explicit constructors
  • Blocking undesirable object instantiation
  • Using member initialization lists
  • The exception specification of an implicitly-declared
  • Default constructor
  • Copy constructor
  • Implicitly-Defined Copy Constructors
  • Implementation –Required Initializations
  • Assignment Operator
  • Implicitly-Defined Assignment Operator
  • Simulating Inheritance of Assignment Operator
  • Blocking Object Copying
  • Destructors
  • Explicit Destructor Invocation
  • Pseudo Destructors
  • Constructors and Destructors Should be Minimal
  • Conclusions

Class Members (Session-1)

  • Static data
  • Static methods
  • Object instance control and sharing
  • A minimal pattern study: singleton and its variance
  • Imitations and extensions

Memory Management Techniques in C++ (Session-2)

  • Types of Storage
  • Automatic storage
  • Static storage
  • Free store
  • POD (Plain Old Data) and non-POD Objects
  • The Lifetime of a POD Object
  • The Lifetime of a non-POD Object
  • Allocation and De-allocation functions
  • Semantics of Allocation functions
  • Semantics of De-allocation functions
  • Malloc() and free() versus new and delete
  • Support for Object Semantics
  • Safety
  • Extensibility
  • New and Delete
  • Allocation and De-allocating arrays using new [ ] and delete [ ]
  • Exceptions and Operator new
  • Exception-Free version of Operator new
  • Placement new
  • Exceptions during object construction
  • Alignment considerations
  • Member alignment
  • The size of a complete object can never be zero
  • User-defined versions of new and delete cannot be declared in a Namespace
  • Overloading new and delete in a class
  • Guidelines for effective memory usage
  • Prefer automatic storage to free store whenever possible
  • Correct syntax for local object instantiation
  • Zero as a universal initializer
  • Always initialize pointers
  • Explicit initializations of POD object
  • Initializing local automatic structs and arrays
  • Union Initialization
  • Detecting a Machine’s Endian
  • The lifetime of a bound temporary object
  • Deleting a pointer more than once
  • Data pointers versus function pointers
  • Pointer equality
  • Storage re-allocation
  • Local static variables
  • Global anonymous unions
  • The const and volatile properties of an object

Extending the Encapsulation in Design (Session-3)

  • Friend and classes
  • Object communication
  • Friend functions
  • Friend classes
  • Const objects and const member functions
  • Object composition & destruction mechanism
  • Boundary classes & object interfaces

Overloading Operator Overloading (Session-4)

  • The operator function and its interpretation w.r.t object expressions
  • Operators that cannot be overloaded
  • Overloading unary and binary operators
  • Using member functions & friend functions – when to us what
  • Function overloading the operator function
  • The assignment operator
  • Implicit overloading mechanism
  • Explicit overloading mechanism
  • Returning objects & assignment operator
  • Overloading >> & << operators
  • Cascading operators & returning reference
  • Overloading new & delete operators
  • Special operator overloads
  • Operator = =, operator [ ], operator ( ), operator ->, operator comma (,)

Objects in Hierarchy Design: Inheritance in C++ (Session-1)

  • Example frameworks that are built on inheritance: TQ, WX Widget
  • Specialization and derived classes
  • Generalization and abstract class, interfaces
  • Types of inheritance
  • Single level, multi-level, multiple, hierarchical, hybrid
  • Inheritance – is it allocation or accessibility
  • The protected access specifier
  • Inheritance in private, protected & public mode
  • Constructors & destructors in a derived class
  • Multiple inheritance
  • Virtual base class
  • Invoking base class constructors
  • Why a constructor is not inherited
  • Is-a & Has-a relationship
  • Nested classes & containership

Runtime Polymorphism, Virtual Functions & Dynamic Binding (Session-2)

  • Pointers & Classes
  • Pointers to class members
  • Method overriding
  • Base class pointers & derived class objects
  • Virtual functions
  • Virtual functions & base class pointers
  • Virtual functions & base class reference
  • Dynamic binding v/s Early binding
  • Pure virtual functions
  • Virtual destructors
  • Abstract classes & application

Runtime Type Identification & Casting Operators (Session-3)

  • Runtime Polymorphism & RTTI
  • Typeid & type_info
  • Application illustration using
  • Base class pointer
  • Passing pointers to functions
  • Function receiving references
  • Factory methods & RTTI
  • Template classes & RTTI
  • The casting operators
  • Dynamic_cast
  • Const_cast
  • Reinterpret_cast

Exception Handling (Session-3)

  • Exception handling fundamentals
  • Try, catch & throw
  • Using multiple catch
  • The ‘catch all’ exception handler
  • Nested try blocks
  • Re-throwing an exception & overruling a function’s
  • Return value
  • Restricting exceptions – the throw list
  • Handling derived class exceptions
  • Setting the terminate and unexpected handlers
  • Application of exception handling

Designing Class Hierarchies Techniques (Session-4)

  • Private data members are preferable to protected ones
  • Declaring virtual base class destructors
  • Virtual member functions
  • Abstract classes and interfaces
  • Use derivation instead of Type-Fields
  • Overloading a member function across class
  • Boundaries
  • Deciding between inheritance and containment
  • The holds-a relation
  • Empty classes
  • Using structs as a shorthand for public classes
  • Friendship
  • Nonpublic inheritance
  • Common root class
  • Forward declarations
  • Local classes
  • Multiple inheritance

Templates in Depth (Session-1 & 2)

  • Implicit instantiation
  • Explicit instantiation
  • Specialization : complete and partial
  • Function templates
  • Class templates
  • Declaration of a class template
  • Instantiation and specialization
  • Explicit specialization of a class template
  • Specializations of class template functions
  • Template arguments
  • Default type arguments
  • Static data members
  • Friendship
  • Function templates
  • Performance considerations
  • Type Equivalence
  • Avoiding unnecessary instantiations
  • Explicit template instantiation
  • Interaction with other language features
  • The typename keyword
  • Inheritance relationship of templates
  • Virtual member functions
  • Pointers to members of a class template

The Design of STL for handling Modern and Complex Data handling (Session-3)

  • Container, Algorithms, and iterators

Important Optimizations in C++ (Session-4)

  • Before optimizing your software
  • Declaration placement
  • Prefer Initialization to assignment
  • Relocating declarations
  • Member-Initialization lists
  • Prefix versus Postfix operators
  • Inline functions
  • Function call overhead
  • Benefits of inline functions
  • What happens when a function that is declared inline
  • Cannot be inlined?
  • Additional issues of concern
  • The Do’s and Don’ts’s of inline
  • Optimizing memory usage
  • Bit fields
  • Unions
  • Speed Optimizations
  • Using a class to pack a long argument list
  • Register variable
  • Declaring Constant Objects as const
  • Runtime overhead of virtual functions
  • Function objects versus function pointers
  • A last resort
  • Disabling RTTI and exception handling support
  • Inline assembly
  • Interacting with the operating system directly