-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (52 loc) · 1.79 KB
/
main.cpp
File metadata and controls
74 lines (52 loc) · 1.79 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
/**
* @file main.cpp
* @author Lizette Navarrete
* @date 2025-02-08
* @brief Tests the Vector class objects
*
* Runs test from the class and makes sure everything is working
*/
#include <iostream>
#include "Vector.h"
using namespace std;
int main(){
// VARIABLES
Vector userVector;
Vector newVector;
int num = 0;
// Test for push_back
cout << "How many elements do you want in the vector: userVector?" << endl;
cin >> num;
for(int i = 0; i < num; i++){
userVector.push_back(i);
}
cout << "userVector contains the numbers: " << endl;
for(int i = 0; i < userVector.size(); i++)
cout << userVector[i] << endl;
// Test for changing the elements
cout << "Index 3 for userVector is " << userVector[3] << ". What element would you like to replace it with (INT-value)";
cin >> num;
userVector[3] = num;
cout << "Here is your new userVector with the changed element:" << endl;
for(int i = 0; i < userVector.size(); i++)
cout << userVector[i] << endl;
// Test for newVector = userVector (ASSIGNMENT OPERATOR)
newVector.push_back(5);
newVector.push_back(2);
cout << "Here are the newVector elements" << endl;
for(int i = 0; i < newVector.size(); i++)
cout << newVector[i] << endl;
cout << "Now we are equaling the content of userVector to the newVector: " << endl;
cout << "========" << endl;
cout << "RESULTS: " << endl;
newVector = userVector;
for(int i = 0; i < newVector.size(); i++)
cout << newVector[i] << endl;
// FINAL TEST: Copy constructor
Vector copy(userVector);
cout << "Now we are initializing a copy constructor Vector called copy. Here is its contents: " << endl;
for(int i = 0; i < copy.size();i++)
cout << copy[i] << endl;
cout << "That is all for now. Goodbye :)" << endl;
return 0;
}