码迷,mamicode.com
首页 > 编程语言 > 详细

C++2

时间:2016-06-22 00:04:25      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:

 

1 引用高级

 

1 引用高级

 

面试中软第1题

int(*z(int x, int(*y)(int)))(int);

z(int x, int(*y)(int))换成T

int(*T)(int);

是函数调用,返回值是函数指针

x是变量

y是函数指针

z是函数,参数有变量,也有函数指针,返回值是函数指针

 

面试中软第2题
int(* & z(int x, int(* & y)(int)))(int);

引用

 

 1 #define _CRT_SECURE_NO_WARNINGS
 2 
 3 #include<iostream>
 4 using namespace std;
 5 
 6 void main()
 7 {
 8     int a[10] = { 1,2,3,4,5,6,7,8,9,10 };
 9     //引用就是给原来的变量有一个别名,都是同一个地址
10     int (&ra)[10](a);//引用数组a
11     int i = 0;
12 
13     for (auto data : ra)//C++11的循环
14     {
15         data = i + 5;
16         cout << data << endl;
17     }
18 
19     cout << a << " " << ra << endl;//输出地址,上下左右4个都一样
20     cout << &a << " " << &ra << endl;//输出地址,上下左右4个都一样
21 
22     system("pause");
23 }

 

 

123

C++2

标签:

原文地址:http://www.cnblogs.com/denggelin/p/5605217.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!