微软暑期实习笔试题

A. const char *pContent; //pContent 是指针,指向的是const char

B. char * const pContent;//pContet 首先是一个const 的变量,然后是一个指针,也就是说是一个const 的指针,指向char

C. char const *pContent;//和A一样,因为const 可以放在类型前,也可以放在类型后

D. const char* const pContent;


5. What is the output of the follow code?
void main(int argc, char* argv[]) {
	int i = 11;
	int const *p = &i;
	p++;
	cout<<*p<<endl;
}
A. 11	B. 12	C. Garbage value	D. Comipler error	E. None of above
Choose: C

一定要仔细!!



Which of the following C++ code is correct: 
  
(A)  
  
int f() 

     int *a = new int ( 3 ); 
     return *a; 

有内存泄露问题
(B) 
  
int* f() 

     int a[ 3 ] = { 1, 2, 3 }; 
     return a; 

//局部变量  
(C) 
  
vector<int> f() 

     vector<int> v( 3 ); 
     return v; 

  
(D) 
  
void f( int* ret ) 

     int a[ 3 ] = { 1, 2, 3 }; 
     ret = a; 
     return; 

//ret 是指针,形参对于指针而言,是值传递。对于f(a),a的值不发生任何变化

//另外要注意,int a[3] = new int [3]是错误的,一定要用指针
(E) 
  
none of above 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值