MCPcopy Create free account
hub / github.com/EricPengShuai/Interview / main

Function main

base_code/decltype.cpp:19–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19int main()
20{
21 int nums[] = {1,2,3,4};
22 vector<int> vec(nums,nums+4);
23 vector<int>::iterator it;
24
25 for(it = vec.begin(); it != vec.end(); it++)
26 cout << *it << " ";
27 cout << endl;
28
29
30 using nullptr_t = decltype(nullptr);
31 nullptr_t nu;
32 int *p =NULL;
33 if(p == nu)
34 cout << "NULL" << endl;
35
36
37 typedef decltype(vec.begin()) vectype;
38
39 for(vectype i = vec.begin(); i != vec.end(); i++)
40 cout << *i << " ";
41 cout << endl;
42
43 /**
44 * 匿名结构体
45 */
46 struct
47 {
48 int d;
49 double b;
50 } anon_s{};
51
52 decltype(anon_s) as{2, 1}; // 定义了一个上面匿名的结构体
53 cout << as.d << endl;
54
55 cout << multiply(11,2) << endl;
56
57 return 0;
58}

Callers

nothing calls this directly

Calls 1

multiplyFunction · 0.85

Tested by

no test coverage detected