home *** CD-ROM | disk | FTP | other *** search
/ Microsoftware Monthly 19…2 Programming Power Tools / MASO9512.ISO / cpptutor / cpptutor.arj / EXAMPLES / EX0412.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-05  |  462 b   |  19 lines

  1. // \EXAMPLES\EX0412.CPP
  2. #include <iostream.h>
  3.  
  4. void f(int* i) {
  5.    *i = 3;     // change the value of what i points to
  6. }
  7.  
  8. void g(int& j) {
  9.    j = 4;      // change the value of the reference
  10. }
  11.  
  12. void main() {
  13.    int i = 0, j = 0;
  14.    f(&i);             // pass a pointer to i to f()
  15.    cout << "Here is i after the call to f(): " << i << endl;
  16.    g(j);              // pass j to g()
  17.    cout << "Here is j after the call to g(): " << j << endl;
  18. }
  19.