Introduction to C++
C++ is the workhorse of many OO systems, and though it has been supplated by Java in many applications, it's still a great language if you need to be close to the hardware or if you need to interface to a large body of existing C code. C++, however, is a large complex language that's difficult to master, and many C++ features, if used haphazardly, can make your code impossible to maintain and debug.
Course Description
This course, for experienced C programmers and technical managers, introduces C++ as a general-purpose Object-Oriented programming language. Since a thorough understanding of C is assumed, we don't waste time covering that part of C++ which is identical to C. We do cover the remainder of C++ language in depth, however, including the hard-to-understand parts of the language like templates. We'll also look beyond the simple syntax at how to apply the language properly in an OO programming environment, putting special emphasis on interface-based programming (which is an essential part of all good OO systems, but is not supported syntactically in C++). Our focus is always on good OO structure, so we also cover several relevant object-oriented-design topics such as fragile base classes and the proper use of accessor and mutators.
Though there is a strong focus on object-oriented programming, note that this class is not a design class, and we strongly recommend that you supplement this class with our OO-Design Workshop Our Design Patterns class also provides good follow up.
The best way to present this class is in a four-day hands-on format. The class can be presented in a 2-day lecture-only format, if all you want is a familiarity with the syntax, but the hands-on component is essential if you intend to actually use the language.
On completion of this class, you will:
- Understand what C++ is, it's benefits and weaknesses.
- Thoroughly understand the syntax and structure of the C++ language.
- Understand how to use the language properly in an OO system.
- Understand the architecture standard libraries, including STL, and how to use them in a general way.
Who Should Attend?
This course is fast paced and technically rigorous. It is intended for professional programmers and technical managers who know C and want to come up to speed on C++ as quickly as possible.
Outline
- A few good C++ books
- Simple Difference From C
- C++ Naming Conventions
- C features not to use
- C++ keywords not in C
- C++ operators not in C
- Avoid printf()
- Simple I/O operations in C++
- extern linkage
- name mangling
- scope operations
- namespaces and "using"
- declarations
- initializers
- strange syntax
- new/delete
- auto_ptr
- references
- type casts (const_cast
(e), etc.) - inline functions
- default arguments
- function overloading
- exceptions
- Object Oriented Design Features
- What is an Object?
- Classes and class definitions
- example
- The "this" pointer
- access privileges (public/private/protected)
- struct/union under classes
- inline methods in classes
- constructors and destructors
- default construction and destruction
- constructor overloading
- constructors in type conversion
- "explicit" keyword
- copy construction
- member-initialization lists
- const members
- Singletons, static members, private constructors
- forward references
- nested classes
- friends
- operator overloading
- global vs. local overloads
- commutativity
- operator=
- type-conversion operators
- operator new(), operator new[])_, operator delete()
- realloc using new
- overloads with special characteristics ( && || ++ -- -> )
- Implementation inheritance (Derivation)
- construction issues
- virtual functions (polymorphism)
- vtables
- pure virtual
- abstract classes
- protected (Template Method)
- multiple inheritance
- order-of-construction issues
- diamond-shaped hierarchies
- fragility and fragile base classes
- Interface inheritance (implements)
- programming to interfaces
- Covariant returns
- virtual destructors
- virtual constructors
- RTTI and typeid
- pointers to members
- Command objects
- An Introduction to Templates
- doing it with macros
- using a template instead
- General template syntax
- template parameters (types, values, class templates)
- implicit template expansion
- explicit template expansion
- explicit "specialization"
- function overloads under templates
- default arguments to templates
- class templates
- using base classes to avoid unnecessary duplication
- templates within templates
- recursive Specialization
- Documentation using Doxygen
- The C++ Standard Library
- standard header files
- accessing C libraries
- characters and localization
- string/wstring
- file I/O (istream, ostream, ifstream, etc.)
- predefined streams
- opening files
- formatted IO
- using cout methods directly
- manipulators
- writing your own manipulators
- The Standard Template Library (STL)
- allocators
- containers
- deque, list, map, multimap, set, multiset, vector
- priority_queue, queue, stack
- bitset, basic_string/string/wstring, vallarray, vector
- iterators
- categories of iterators
- iterator, const_iterator, reverse_iterator, const_reverse_iterator
- algorithms
- OO issues
- functors
- comparison algorithms
- searching algorithms
- modifying algorithms
- sorting
- merging
- set operations
- heap operations
- permutations
- writing custom algorithms
