首页 > 试题广场 >

阅读下列程序,写出运行结果: #include usi

[问答题]
阅读下列程序,写出运行结果:
#include <iostream>
using namespace std;
void test1( int *a1 )
{
a1 = new int( 5 );
cout << "*a1 = " << *a1 << endl;
}
void test2(int * & a2)
{
a2 = new int( 5 );
cout << "*a2 = " << *a2 << endl;
}
int main()
{
int *p = new int( 1 );
test1( p );
cout << "test1: *p1 = " << *p << endl;
test2( p );
cout << "test2: *p2 = " << *p << endl;
}

推荐

*a1= 5

test1: *p1= 1

*a2= 5

test2: *p2= 5

发表于 2018-05-07 11:40:32 回复(1)