* in the following code?
int* pt;(b)
* in the following code?
int* pt=new int; *pt = 5;(c)
& in the following code?
int function(int& x, int y);(d)
& in the following code?
int x; int *pt = &x;(2)
#include<iostream>
using namespace std;
typedef int* IntPtr;
int main() {
int *a, b, *c;
int* d, e, f;
IntPtr i, j, k;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
char *pt, ch='a';
pt = &ch;
cout << ch << endl;
cout << *pt << endl;
ch = 'c';
cout << ch << endl;
cout << *pt << endl;
*pt = 'e';
cout << ch << endl;
cout << *pt << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
char *pt, ch1='a', ch2='b';
pt=&ch1;
cout << ch1 << "," << ch2 << "," << *pt << endl;
ch1='A';
ch2='B';
cout << ch1 << "," << ch2 << "," << *pt << endl;
*pt='P';
cout << ch1 << "," << ch2 << "," << *pt << endl;
pt=&ch2;
cout << ch1 << "," << ch2 << "," << *pt << endl;
ch1='X';
ch2='Y';
*pt='Z';
cout << ch1 << "," << ch2 << "," << *pt << endl;
pt=&ch1;
cout << ch1 << "," << ch2 << "," << *pt << endl;
ch1=ch2;
*pt=ch2;
ch2='#';
ch1='A';
cout << ch1 << "," << ch2 << "," << *pt << endl;
pt=new char;
ch1='1';
ch2='2';
*pt='3';
cout << ch1 << "," << ch2 << "," << *pt << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int *pt1, *pt2, x=5, y=7;
pt1=&x;
pt2=&y;
cout << x << "," << *pt1 << "," << y << "," << *pt2 << endl;
(*pt1)+=5;
y--;
cout << x << "," << *pt1 << "," << y << "," << *pt2 << endl;
*pt1=9;
*pt2=10;
cout << x << "," << *pt1 << "," << y << "," << *pt2 << endl;
pt1=&y;
y++;
cout << x << "," << *pt1 << "," << y << "," << *pt2 << endl;
pt2=pt1;
x=100;
cout << x << "," << *pt1 << "," << y << "," << *pt2 << endl;
pt1=new int;
*pt1=37;
cout << x << "," << *pt1 << "," << y << "," << *pt2 << endl;
pt2=new int;
pt1=&x;
*pt2=22;
*pt1=87;
y=19;
cout << x << "," << *pt1 << "," << y << "," << *pt2 << endl;
y=x;
x=-3;
cout << x << "," << *pt1 << "," << y << "," << *pt2 << endl;
*pt2=*pt1;
y=1;
cout << x << "," << *pt1 << "," << y << "," << *pt2 << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int* pt1, pt2;
pt2=new int;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int* pt, x;
pt = x;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int* pt, x=6;
cout << x;
cout << *pt;
return 0;
}
|