[prev] 79 [next]

Defining New Data Types (cont)

Reasons to use typedef:
  • give meaningful names to value types   (documentation)
    • is a given number Temperature, Dollars, Volts, …?
  • allow for easy changes to underlying type

    typedef float Real;
    Real complex_calculation(Real a, Real b) {
    	Real c = log(a+b); … return c;
    }
    

  • "package up" complex type definitions for easy re-use
    • many examples to follow; Matrix is a simple example