home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IDIOMS.ZIP / 5-23.C < prev    next >
C/C++ Source or Header  |  1991-12-04  |  968b  |  22 lines

  1. /* Copyright (c) 1992 by AT&T Bell Laboratories. */
  2. /* Advanced C++ Programming Styles and Idioms */
  3. /* James O. Coplien */
  4. /* All rights reserved. */
  5.  
  6. int main() {
  7.     Value *v = new Value(100,1260); // voltage at a frequency
  8.     BPF bpf(1000, 10000);    // a band-pass filter
  9.     HPF hpf(1100);           // a high-pass filter
  10.     LPF lpf(8000);           // a low-pass filter
  11.     Filter *a;               // a pointer to a filter
  12.     a = (Filter*)bpf(&hpf);  // apply a band-pass filter to a
  13.     a->print();              //   high-pass filter:  result?
  14.     (*a)(v)->print();        // apply to a voltage and print
  15.     a = (Filter*)(*a)(&lpf); // apply that to a low-pass
  16.     a->print();              //   filter:  whaddya get?
  17.     a = (Filter*)(*a)(v);    // now apply voltage to input
  18.     a->print();              //   of all that, and print
  19.     lpf(&hpf)->print();      // combine low- & high-pass
  20.     return 0;                //   filters
  21. }
  22.