Difference between revisions of "OOP344 ljubomir notes"

From CDOT Wiki
Jump to: navigation, search
(Week 5 - Oct 4)
(Week 6 - Oct 11)
Line 46: Line 46:
 
==Week 6 - Oct 11==
 
==Week 6 - Oct 11==
  
Dynamic Memory Allocation
+
'''Dynamic Memory Allocation'''
  
 
You need:
 
You need:
  
 
#a pointer for the data type that will occupy the memory whose address you will point to
 
#a pointer for the data type that will occupy the memory whose address you will point to
 +
*int* p;
 
#if the pointer is already pointing at another already allocated memory, deallocate it
 
#if the pointer is already pointing at another already allocated memory, deallocate it
 +
#allocate memory and set the pointer to its address
 +
#use the memory
 +
#when you are done, deallocate it
 +
*delete[] p;
  
 
=Discussion=
 
=Discussion=

Revision as of 18:23, 31 October 2009

Overview

Week 2 - Sep 13

  • define
  • include
  • macros
  • operators
  • statement evaluation
  • return value of main
  • return value of printf & scanf
  • conditional compilation

Week 3 - Sep 20

  • pointers
  • pointer arithmetic
  • pointers to pointers to pointers... etc.
  • logical operators and pointers

Week 4 - Sep 27

  • undef (#undef)
  • casting
  • unsigned variables
  • multi-dimentional arrays and their pointer notation
  • pointers to functions
  • pointers to pointers to pointers... etc.
  • typedef, enum

Week 5 - Oct 4

  • bits, bitwise operators
  • a jump ahead and review!
    • C++
    • inheritance
    • polymorphism
    • encapsulation
  • default parameters
  • forward declaration
  • initialization vs. setting
  • vitual methods
  • pure virtual methods
  • abstract base classes

Week 6 - Oct 11

Dynamic Memory Allocation

You need:

  1. a pointer for the data type that will occupy the memory whose address you will point to
  • int* p;
  1. if the pointer is already pointing at another already allocated memory, deallocate it
  2. allocate memory and set the pointer to its address
  3. use the memory
  4. when you are done, deallocate it
  • delete[] p;

Discussion