欢迎来到弘毅网!本网站现已开通校园用户注册,校园用户仅限合作校园IP段内注册!已注册的校园用户账号可于校外免费访问本资源库!

文章列表

笔试题

当前位置:主页 > 求职就业 > 面试笔试 > 笔试题 > 正文

阿尔卡特的一个笔试题

时间:2016-01-13 11:01 作者: 来源: 人气:

ATest.cpp : Defines the entry point for the console application.

//参数传递问题

  1. include "stdafx.h"
  1. include <iostream>

using namespace std;

void fun(int a,int*b,int &c,int* &d)

{

 a++;

 (*b)++;

 b = new int(10);

 cout<<"aaaa "<<b<<endl;//地址

 cout<<"bbbb "<<*b<<endl;//5

 c++;

 d++;

 d = new int(5);

 cout<<"dddd "<<d<<endl;//地址

 cout<<"dddd2 "<<*d<<endl;//5

}

int main(int argc, char* argv[])

{

 int a=2,b=3,c=4,d=5;

 int* p = &d;

 fun(a,&b,c,p);

 cout<<a<<endl;//2 值传递

 cout<<b<<endl;//4 指针传递

 cout<<c<<endl;//5 引用传递

 cout<<d<<endl;//5 引用传递 指向指针的引用

 cout<<*p<<endl;//10 引用传递 int(5)为整型初始化

// printf("Hello World!");

 return 0;

}

(责任编辑:职场达人)