-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
81 lines (58 loc) · 1.78 KB
/
Copy pathmain.cpp
File metadata and controls
81 lines (58 loc) · 1.78 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
/**
* @file main.cpp
* @author your name (you@domain.com)
* @brief
* @version 0.1
* @date 2022-12-23
*
* @copyright Copyright (c) 2022
*
*/
#include<iostream>
#include "xy_vector.cpp"
using namespace std;
int main(){
// entering an array to vector
int arr[5] = {8,9,10,11,12};
xyVector<int> array(arr,5);
// pushing back items
xyVector<int> v;
v.push_back(4);
v.push_back(5);
v.push_back(6);
v.push_back(7);
v.push_back(8);
v.push_back(9);
v.push_back(10);
v.push_back(11);
v.push_back(12);
cout << "iterating with iterators : \n";
xyVector<int>::iterator iter = v.begin();
for(iter = v.begin(); iter != v.end() ; iter++){
cout << *iter << ((iter != v.end() - 1) ? "," : "");
}
cout << '\n';
cout << "erase the iterator erase(v.begin() + 1) : ";
v.erase(v.begin() + 1);
for(int i = 0; i != v.size() ; i++){
cout << v[i] << (( i != v.size() - 1) ? "," : "");
}
cout << '\n';
cout << "erase(v.begin(),v.begin() + 2)) : ";
v.erase(v.begin(),v.begin() + 2);
for(int i = 0; i != v.size() ; i++){
cout << v[i] << (( i != v.size() - 1) ? "," : "");
}
cout << '\n';
cout << "printing the vector with << operator : ";
cout << v << '\n';
cout << "comparing with == operator (v == array) : ";
cout << (v == array) << '\n';
cout << "resizing to 20 elements : ";
v.resize(20);
cout << v << '\n';
cout << "insert(v.begin(),7) : ";
v.insert(v.begin(),7);
cout << v << '\n';
return 0;
}