forked from pezy/CppPrimer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex6_23.cpp
More file actions
47 lines (39 loc) · 743 Bytes
/
Copy pathex6_23.cpp
File metadata and controls
47 lines (39 loc) · 743 Bytes
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
#include <iostream>
using std::cout;
using std::endl;
using std::begin;
using std::end;
void print(int* pi)
{
if (pi) cout << *pi << endl;
}
void print(const char* p)
{
if (p)
while (*p) cout << *p++;
cout << endl;
}
void print(const int* beg, const int* end)
{
while (beg != end) cout << *beg++ << endl;
}
void print(const int ia[], size_t size)
{
for (size_t i = 0; i != size; ++i) {
cout << ia[i] << endl;
}
}
void print(const int(&arr)[2])
{
for (auto i : arr) cout << i << endl;
}
int main()
{
int i = 0, j[2] = {0, 1};
char ch[5] = "pezy";
print(ch);
print(begin(j), end(j));
print(&i);
print(j, end(j) - begin(j));
print(const_cast<const int(&)[2]>(j));
}