You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
436 B

2 years ago
//6.2.4.2数组参数.cpp
#include <iostream>
using namespace std;
void showarr(int *&a);
void showptr(int *&a);
int main(){
int arr[]={1,4,7},*p=arr;//使用这个例子中的做法需要先把数组显式转化为指针
showarr(p);
int a=12,*ptr=&a;
showptr(ptr);
cout << a << endl;
return 0;
}
void showarr(int *&a){
cout << *a << endl;
a++;
cout << *a << endl;
}
void showptr(int *&a){
cout << *a << endl;
*a=11;
}