You are on page 1of 2

CSCE 121

Doubly linked list:


Pros – able to travel both directions, easily print the reverse
Cons – More pointers make it harder to manage and require more memory
Destructor:
Called when an object goes out of scope on the stack
Also when a pointer gets deleted
Shallow Copy:
Pointer addresses are copied
Deep Copy:
Each identifier has same value, different memory addresses
Copy Constructor: (learn implementation)
Is an overloaded constructor that ensures deep copies occur
Copy Assignment: (learn implementation)
An overloaded = operator that ensures deep copies occur; must not self-assign, deletes
old data, returns reference to self

RULE OF THREE GOOD FOR MEMORY MANAGEMENT

BOTH: have parameter of constant reference to source object of same type, allocate
new memory and copy data from source
MOVE SEMANTICS:

Lvalues: live beyond an expression (variables)


Rvalues: are temporary
Pilfer dynamic parts from a temporary object to save time (why return
something that is just going to get copied?); gets destroyed immediately

Move Constructor and Move Assignment do same thing as Copy, excepts Move does not
allocate new memory or copy data from a source
Important because of efficiency since instead of copying something that will be
destroyed, we are moving its value to something that will live (Lvalue)

RULE OF FIVE GOOD FOR EFFICIENCY

IN THE INHERTIED CLASS, DO CONSTRUCTORS/OPERATOR= GET INHERTIED? WHAT ARE


PROS/CONS OF INHERITANCE
PROS: can have a list mixed objects, call base class function, polymorphism, don’t have to
create master class
CONS: complication
Polymorphism:
A method is indicated and, regardless of its underlying type, it will do what is
appropriate for that type
Useful: when we can override the parent class’ version
VIRTUAL: indicated in the parent class that the child’s function should be used;
use when you want the option of overriding function
PURE VIRTUAL (abstract): indicated in the parent class; will not compile if not
found in derived class; use when you want to force derived classes to override
function
POWERPOINT 14
Shape* S1 = new Circle(3);
Class* c = (Class*) S1;
IS-a vs HAS-a relationship
Truck is a vehicle
A vehicle has an engine

Handle; when a button is pressed, an event is triggered, the handle is called;


Callback; tells the program what to do when the event is triggered (button is pushed)

Template Sytnax: template <typename T1>


Generic Programming generalizing algorithms and data structures
Pros: increased correctness, greater range of uses, and better performance

You might also like