Polymorphism, Virtual Functions, Abstract Base Class - Ch. 15
- Aggregation - The instance of a class within another class. "Has A"
relationship
- Inheritance - A derived class will inherit all members of a base class.
"Is A" relationship.
- Polymorphism - Allows a Base Class pointer or Base &reference variable
to call the correct member functions, depending upon the type of object
being referenced. "Many Things". Must be a Base Class pointer or Base
&reference variable.
- Base Class Pointers - Pointers to a base class may point to derived class
objects. ex. Base* base = new Base; Base* base = new Derived;
Base* base = &baseObj; Base* base = &derivedObj;
- Virtual Functions
- Static Linking vs Dynamic Linking ("late binding")
- Abstract Base Class - An ABC is never instantiated, serves as a base
class for derived. Represents generic or abstract form of all derived
classes (Interface). Must contain at least one pure virtual member
function.
- Pure Virtual Functions = 0; - Pure virtual functions have no body or
definition within the base class. Must be overridden in a derived class.
GNU Debugger - GDB
- compile with -g flag to enable debugging information:
g++ -g source.cpp -o exec
- Use -Wall to show all warnings:
g++ -g -Wall source.cpp -o exec
- ulimit -c unlimited - allow a segFault create a core dump file
- gdb ./exec
- gdb ./exec core
- break - set break points at function or line number
- run
- step, s
- next, n
- continue, c
- info locals
- info args
- print variable
- print &variable
- print *ptr
- backtrace, bt
- frame #