diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.cpp b/homework/vector-of-shared-ptrs/vectorFunctions.cpp new file mode 100644 index 00000000..bc86adff --- /dev/null +++ b/homework/vector-of-shared-ptrs/vectorFunctions.cpp @@ -0,0 +1,32 @@ +#include "vectorFunctions.hpp" + +std::vector> generate(int count) { + std::vector> vec; + for (int i = 0; i < count; i++) { + vec.push_back(std::make_shared(i)); + } + return vec; +} +void print(const std::vector>& vec) { + for (const auto& num : vec) { + std::cout << *num << "\n"; + } +} + +void add10(std::vector>& vec) { + for (auto& num : vec) { + if (num) { + *num += 10; + } + } +} +void sub10(int* const num) { + if (num) { + *num -= 10; + } +} +void sub10(std::vector> vec) { + for (auto& num : vec) { + sub10(num.get()); + } +} \ No newline at end of file diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.hpp b/homework/vector-of-shared-ptrs/vectorFunctions.hpp new file mode 100644 index 00000000..d53743c6 --- /dev/null +++ b/homework/vector-of-shared-ptrs/vectorFunctions.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include +#include +#include + +std::vector> generate(int count); +void print(const std::vector>& vec); +void add10(std::vector>& vec); +void sub10(int* const num); +void sub10(std::vector> vec); \ No newline at end of file