Lectures 7 - 10 Flashcards
(18 cards)
Variables are placed on . . .
The stack
Memory management happens . . .
Automatically, at compile time, and when there is little to do.
The stack is
A small amount of memory managing function calls and automatic variables
Heap
The rest of the addressable memory
Deal with memory allocation and de-allocation
Why should you keep a pointer to the data alive?
You won’t be able to free it.
The development of programming languages has diverged.
- Imperative/procedural
- Declarative
- Functional
- Object-oriented
OO languages
Most used paradigm for commercial software.
Global (Scope)
Visible anywhere.
Local (Scope)
Visible only in local function/block
Object (Scope)
Public: Visible from the object
Private: Only visible to the object
Protected: The object and child types
Encapsulation
Make data inside private
Abstraction
Only provide essential info to the outside world and hide the internals of the object.
Class
A template describing what data and methods an object should support
Vector
Able to get around the problems of arrays
Destructor
Called when the object is destroyed.
Buffer
A temporary store for data entered by the user
Buffer overflow
Fill the array and continue writing until the return address
Solutions for attacks.
- Avoid the use of functions that perform unbounded writes.
- Use fgets instead of gets. Lets you specify the maximum number of characters to read in.
- Modern compilers and operating systems also offer some protection.
- Write good code. Writing bad code leads to poor software.