One aspect of C++ that makes it very powerful is its ability to package code in several different ways.
Table 7.1 defines some terms that are used to describe containers of code. The table is arranged (approximately) in order of increasing granularity from top to bottom.
Term |
Visible attributes |
Description |
---|---|---|
class |
class Classname { body } ; |
A collection of functions and data members, and descriptions of its lifecycle management (constructors and destructors) |
namespace |
namespace name { body } ; |
A collection of declarations and definitions, of classes, functions and static members, perhaps spanning multiple files |
header file |
.h |
Class definitions, template definitions, function declarations (with default argument definitions), inline definitions, static object declarations |
source code module |
.cpp |
Function definitions, static object definitions |
compiled "object" module |
.o or .obj |
Each .cpp module is compiled into a binary module as an intermediate step in building a library or executable. |
library |
.lib or .la (+ .so or .dll if dynamic) |
An indexed collection of object files linked together. No main() function must exist in any code module in a library. |
devel package |
lib + header files |
A library along with accompanying header files |
application |
.exe on windows, no particular extension on *nix |
A collection of object files, linked with libraries, to form an application. Contains exactly one function definition called main(). |
Reusing Other Libraries |
Part I: Introduction to C++ and Qt 4
C++ Introduction
Classes
Introduction to Qt
Lists
Functions
Inheritance and Polymorphism
Part II: Higher-Level Programming
Libraries
Introduction to Design Patterns
QObject
Generics and Containers
Qt GUI Widgets
Concurrency
Validation and Regular Expressions
Parsing XML
Meta Objects, Properties, and Reflective Programming
More Design Patterns
Models and Views
Qt SQL Classes
Part III: C++ Language Reference
Types and Expressions
Scope and Storage Class
Statements and Control Structures
Memory Access
Chapter Summary
Inheritance in Detail
Miscellaneous Topics
Part IV: Programming Assignments
MP3 Jukebox Assignments
Part V: Appendices
MP3 Jukebox Assignments
Bibliography
MP3 Jukebox Assignments