<pre name="code" class="cpp">#include <iostream>
using namespace std;
void print_arry(ostream& os, int* a, int x)//参数是:输出流对象,int类型的指针, int类型
{
for (int i = 0; i < x; i++)
os << a[i] << endl;
}
int main()
{
//主函数中给出实参
int n = 20;
int* parr = new int[20];
for (int k = 0; k < n; k++)
{
parr[k] = 100 + k;
}
ostream& os = cout;
//调用函数时,将实参放在形参的位置上,形实结合
print_arry(os, parr, n);
delete[]parr;
system("pause");
return 0;
}