Abstract Data Types (ADT)
Procedural Programming – data and functions are separate and distinct
Object-oriented programming
Object/Class
Access Specifiers
o public:
o private:
o can be listed in any order, multiple times, default is private
Member variables (attributes)
Member functions (methods)
o Acessor, get, getter function – reads/used but does not modify a member variable
o Mutator, set, setter function – modifies a member variable
o inline member functions (preprocessor replaces text, larger executable, less overhead)
o regular member functions (allocates memory, possibly slower execution)
function prototype within class definition
function definition outside class definition
scope resolution operator (::) – used on function definition
o Constructor Square() Square x(8);
Must be public
Must be named the same as the class
Must have no return type
Overloading constructors
Default constructor
Takes no arguments
(due to no parameters or all have defaults)
o Destructor ~Square
Automatically called when object is destroyed
Has no return type
Takes no arguments
Only 1 destructor per class (cannot be overloaded)
Using separate files
o Class specification file ([Link])
o Class implementation file ([Link])
o Use #include in the .cpp file and the [Link]
o Pre-Processor Guards
#ifndef symbol_name
#define symbol_name
#endif
Structure
o Declaration
Structure name (tag)
Structure members
Semi-colon
o Access members using dot (.) operator
o Compare members variables, not structure variables
o Initializing a structure
at time structure variable is created
use initialization list
o Nested structures
Searching
o Linear
o Binary
o Key Field
o Search Key
Sorting
o Bubble
o Selection
Algorithm Analysis
o Basic Step (constant amount of time)
o Worst-case complexity
o Average case complexity
o Big O Notation