-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinitializers.cpp
More file actions
44 lines (37 loc) · 993 Bytes
/
initializers.cpp
File metadata and controls
44 lines (37 loc) · 993 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
//*****************************************************************************
//
// Author: Michael Price
// License: Attribution-NonCommercial-NoDerivs 3.0 Unported
// http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode
//
//*****************************************************************************
#include <vector>
#include <iostream>
#include <initializer_list>
using namespace std;
void i_wasted_all_the_bits_in_this_name ()
{
int numArray[] = {3, 1, 4, 1, 5};
// Good thing I don't have to use
// push_back()!
//
vector<char> vChars = {'A', 'D', 'G',
'J', 'M', 'Q', 'U', 'Z'};
for (auto s : {"Hello", "World"})
{
cout << s << endl;
}
}
class RememberTheInitialSize
{
public:
RememberTheInitialSize (std::initializer_list<int> il)
: m_initialSize(il.size())
{ }
private:
size_t m_initialSize = 0;
};
void what_was_that_size_again ()
{
RememberTheInitialSize please = {1, 6, 1, 8, 0, 3};
}