#include <iostream>
using namespace std;
void func1()
{
int *b;
int a = 10;
b = &a;
cout << *b << endl;
}
void func2()
{
int num = 7;
int *p = #
cout << "数值" << num << "所在地址为:" << p << endl;
cout << "指针p所指向的地址为:" << p << ", 该地址上所保存的值为:" << *p << endl;
*p = 100;
cout << "指针p所指向的地址为:" << p << ", 该地址上所保存的值为:" << *p << endl;
}
void func3()
{
int num = 7, another = -5;
int *p = #
p = &another;
cout << *p << endl;
}
void func4()
{
int val = 7, val2 = 999;
int &refval = val, &refval2 = val2;
refval = -12;
printf("%d %d\n", val, refval);
refval = refval2;
printf("%d %d\n", val, refval);
}
void func5()
{
int val = 100;
int &refval = val;
cout << refval << endl;
val = 10;
cout << refval << endl;
refval = 20;
cout << val << endl;
}
void func6()
{
int a = 10;
int b = 20;
int *p = &a;
cout << *p << endl;
int *&q = p;
cout << *q << endl;
p = &b;
cout << *q << endl;
cout << *p << endl;
}
int main()
{
}
|