-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFunction.h
More file actions
90 lines (67 loc) · 1.79 KB
/
Function.h
File metadata and controls
90 lines (67 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
using namespace std;
//the main function cannot be overloaded ,recursived
void useOfinitializer_list(initializer_list<string> l)
{
cout << "useOfinitializer_list" << endl;
for (auto beg = l.begin(); beg != l.end();beg++)
{
cout << *beg << endl;
}
}
void useOfvectorPara(vector<int> vec)
{
cout << "useOfvectorPara" << endl;
for (auto c : vec)
{
cout << c << endl;
c = 1;
}
}
void useOfcomplicatedVectorPara(vector<vector<int> > comVec)
{
cout << "useOfcomplicatedVectorPara" << endl;
for (auto iter = comVec.begin(); iter != comVec.end();++iter)
{
for (auto iter_iner = (*iter).begin(); iter_iner != (*iter).end();++iter_iner)
{
*iter_iner = 1;
}
}
}
void printOfcomplicatedVectorPara(vector<vector<int> > comVec)
{
cout << "printOfcomplicatedVectorPara" << endl;
for (auto iter = comVec.begin(); iter != comVec.end();++iter)
{
for (auto iter_iner = (*iter).begin(); iter_iner != (*iter).end();++iter_iner)
{
cout << *iter_iner ;
}
cout << endl;
}
}
vector<string> useOfReturnValueofListInitializing()
{
cout << "useOfReturnValueofListInitializing" << endl;
return{ "sfsdf", "sfdsdfa", "sdfadf" };
}
/*
int (*funOfReturnPointertoArray(int i))[10]
{
}
*/
//trailing return type
/*
A trailing return type follows the parameter list and is preceded
by ->. To signal that the return follows the parameter list, we use auto where the
return type ordinarily appears:
*/
auto func(int i) -> int(*)[10];//this is a function that return a pointer to array
//overloaded function
//It is an error for two functions to differ only in terms of their return types
/*
Local variables may not be used as a default argument. Excepting that restriction,
a default argument can be any expression that has a type that is convertible to the
type of the parameter
*/