blob: f1bad84148ced3009644a1439a319244a1f799bc (
plain)
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
|
#include <iostream>
#include <vector>
#include "sales_data.hpp"
#include "sales_item.hpp"
/*
*
* 3.21
*
*
*/
using std::string;
using std::cout;
using std::cin;
using std::cerr;
using std::clog;
using std::endl;
using std::vector;
void cout_vector_int_iterator(vector<int> vx) {
for(auto itr = vx.cbegin() ; itr != vx.cend() ; itr++) {
cout << "'" << *itr << "'";
}
cout << endl;
}
void cout_vector_string_iterator(vector<string> vxs) {
for(auto itr = vxs.cbegin() ; itr != vxs.cend() ; itr++) {
cout << "'" << *itr << "'";
}
cout << endl;
}
int main () {
vector<int> v1; // 0 elements?
vector<int> v2(10); // 10 elements, default initialized
vector<int> v3(10, 42); // 10 elements, all initialized to 42
vector<int> v4{10}; // 1 element, initialized to 10.
vector<int> v5{10, 42}; // 2 elements, first one 10, second one 42
vector<string> v6{10}; // Not really valid but it creates 10 elements of default initialized strings. Empty strings.
vector<string> v7{10, "hi"}; // Not really valid but creates 10 elements that says "hi"
cout_vector_int_iterator(v1);
cout_vector_int_iterator(v2);
cout_vector_int_iterator(v3);
cout_vector_int_iterator(v4);
cout_vector_int_iterator(v5);
cout_vector_string_iterator(v6);
cout_vector_string_iterator(v7);
return 0;
}
|