summaryrefslogtreecommitdiff
path: root/3p13.cpp
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-08-07 16:35:33 +0200
committerOskar <[email protected]>2024-08-07 16:35:33 +0200
commita805c55e5b870ec3f65ce9dd5fdf6f5456a62ac3 (patch)
tree4a6a6a1635eb257b1c7a40943f0de23f4e5f456a /3p13.cpp
parentcb72c34ff23c8c6c2e6b8376d1cf8a5ca5b9becb (diff)
more exercises
Diffstat (limited to '3p13.cpp')
-rw-r--r--3p13.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/3p13.cpp b/3p13.cpp
new file mode 100644
index 0000000..ca60b58
--- /dev/null
+++ b/3p13.cpp
@@ -0,0 +1,37 @@
+#include <iostream>
+#include <vector>
+#include "sales_data.hpp"
+#include "sales_item.hpp"
+
+/*
+ *
+ * 3.13
+ *
+ *
+ */
+
+using std::string;
+using std::cout;
+using std::cin;
+using std::cerr;
+using std::clog;
+using std::endl;
+using std::vector;
+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"
+
+ // some extra testing below
+ vector<string> v8(10); // same as v6?
+ vector<string> v9(10, "hi"); // Same as v7?
+
+ cout << v7[1] << endl;
+ cout << v9[1] << endl;
+ return 0;
+}