diff options
author | Oskar <[email protected]> | 2024-08-11 20:59:53 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-08-11 20:59:53 +0200 |
commit | 06615448f1fd8378817e8ef72b5347ae3f0c3577 (patch) | |
tree | fc89a7edaee13953211d006a9c1a428dd279247c /3p32.cpp | |
parent | b45c0d29ee690c8b436a33581d3b108e6064b5a7 (diff) |
more
Diffstat (limited to '3p32.cpp')
-rw-r--r-- | 3p32.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/3p32.cpp b/3p32.cpp new file mode 100644 index 0000000..2510e21 --- /dev/null +++ b/3p32.cpp @@ -0,0 +1,59 @@ +#include <iostream> +#include <vector> +#include "sales_data.hpp" +#include "sales_item.hpp" + +/* + * + * 3.32 + * + * + */ + +int main () { + + constexpr size_t ArraySize = 10; + int MyArray[ArraySize]; + int MyArray2[ArraySize]; + for(size_t Index = 0 ; Index != ArraySize ; ++Index) { + MyArray[Index] = Index; + } + + for(size_t Index = 0 ; Index != 10 ; ++Index) { + MyArray2[Index] = MyArray[Index]; + } + + for(auto i : MyArray) { + std::cout << i << std::endl; + } + + std::cout << std::endl; + for(auto i : MyArray2) { + std::cout << i << std::endl; + } + + std::cout << std::endl; + + // Vector version + size_t VecSize = 10; + std::vector<int> MyVec; + std::vector<int> MyVec2; + for(size_t Index = 0 ; Index != VecSize ; ++Index) { + MyVec.push_back(Index); + } + + MyVec2 = MyVec; + // If we wanted to we could also initialize MyVec2 here instead of above + // std::vector<int> MyVec2 = MyVec; + + for(auto i : MyVec) { + std::cout << i << std::endl; + } + + std::cout << std::endl; + for(auto i : MyVec2) { + std::cout << i << std::endl; + } + + return 0; +} |