home *** CD-ROM | disk | FTP | other *** search
- // **************************************************************
- // pointer.cpp
- // Example program for Simple C++
- //
- // (c) 1999 Emmenjay Consulting Pty Ltd
- //
- // History
- // 05/05/99 MJS Initial Coding.
- //
- // **************************************************************
-
- #include <iostream>
-
- int main( void )
- {
- int i=3, j=6;
- int *p;
-
- std::cout << "i and j = " << i
- << " and " << j << '\n';
- p = &i;
- std::cout << "*p (pointing to i) = "
- << *p << '\n';
- p = &j;
- std::cout << "*p (pointing to j) = "
- << *p << '\n';
-
- *p = 9; // THIS MODIFIES J
- std::cout << "i and j = " << i
- << " and " << j << '\n';
-
- return 0;
- }
-