Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void f(int *p);
- ///////////////////////////////////////////////////////
- int main()
- {
- int n = 57;
- int *p = &n;
- std::cout << "Address &n = " << &n << std::endl;
- f(&n);
- }
- ///////////////////////////////////////////////////////
- void f(int *p2)
- {
- cout << "&n = " << p2 << endl;
- cout << " n = " << *p2 << endl;
- int &r = *p2;
- cout << " r = n = " << r << endl;
- cout << "&r = " << &r << endl;
- // std::cout << "size of n = " << sizeof(int) << std::endl;
- // std::cout << " n = " << n << std::endl;
- // std::cout << " &n = " << &n << std::endl;
- }
- /*
- #include <iostream>
- using namespace std;
- int n = 57;
- int *p = &n;
- ///////////////////////////////////////////////////////
- int main()
- {
- std::cout << "size of n = " << sizeof(int) << std::endl;
- std::cout << " n = " << n << std::endl;
- std::cout << " &n = " << &n << std::endl;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement