From a805c55e5b870ec3f65ce9dd5fdf6f5456a62ac3 Mon Sep 17 00:00:00 2001 From: Oskar Date: Wed, 7 Aug 2024 16:35:33 +0200 Subject: more exercises --- 3p13.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 3p13.cpp (limited to '3p13.cpp') 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 +#include +#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 v1; // 0 elements? + vector v2(10); // 10 elements, default initialized + vector v3(10, 42); // 10 elements, all initialized to 42 + vector v4{10}; // 1 element, initialized to 10. + vector v5{10, 42}; // 2 elements, first one 10, second one 42 + vector v6{10}; // Not really valid but it creates 10 elements of default initialized strings. Empty strings. + vector v7{10, "hi"}; // Not really valid but creates 10 elements that says "hi" + + // some extra testing below + vector v8(10); // same as v6? + vector v9(10, "hi"); // Same as v7? + + cout << v7[1] << endl; + cout << v9[1] << endl; + return 0; +} -- cgit v1.2.3