| | | | | |

Proper Types

  • A type is called proper under any of these circumstances:
    1. It is a native type.
    2. It is a class with constructor, destructor, copy constructor, and assignment operator that manage the type as if it were a native type.
    3. It is a user defined type (class) whose variables are proper types.
  • Client programs can use the type exactly as if it were a native type
  • {
      IntArray a;         // IntArray with default number of elements
      IntArray b(100);    // IntArray with 100 elements
      IntArray c(100,-1); // IntArray with 100 elements each initialized to -1
    ...
      b = a;
    ...
      a = b = c;
    ...
    }
    // destructor for each object a, b, c is called as they go out of scope
    // order of destruction is reverse of order of declaration
    

| | Top of Page | 6. C++ Classes Part 2: Advanced Features - 10 of 22