diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.cpp b/homework/vector-of-shared-ptrs/vectorFunctions.cpp new file mode 100644 index 00000000..25643826 --- /dev/null +++ b/homework/vector-of-shared-ptrs/vectorFunctions.cpp @@ -0,0 +1,44 @@ +// +// Created by stefx on 7/7/24. +// + +#include "vectorFunctions.hpp" + +std::vector> generate(int count) { + std::vector> value; + + for (int i = 0; i < count; i++) { + value.push_back(std::make_shared(i)); + } + + for (int it = 0; it < count; it++) { + std::cout << "wynik to: " << *(value[it]); + } + return value; +} + +void print(std::vector> printVector) { + for (const auto& it : printVector) { + std::cout << "Print: " << *it << std::endl; + } +} + +void add10(std::vector> addVector) { + for (auto it : addVector) { + if (it != nullptr) { + *it += 10; + } + } +} + +void sub10(int* const subVector) { + if (subVector != nullptr) { + *subVector -= 10; + } +} + +void sub10(std::vector> przeciazenieVector) { + for (auto it : przeciazenieVector) { + sub10(it.get()); + } +} diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.hpp b/homework/vector-of-shared-ptrs/vectorFunctions.hpp new file mode 100644 index 00000000..35207a72 --- /dev/null +++ b/homework/vector-of-shared-ptrs/vectorFunctions.hpp @@ -0,0 +1,17 @@ +// +// Created by stefx on 7/7/24. +// + +#ifndef VECTOROFSHAREDPOINTERS_VECTORFUNCTIONS_HPP +#define VECTOROFSHAREDPOINTERS_VECTORFUNCTIONS_HPP +#include +#include +#include + +std::vector> generate(int count); +void print(std::vector> printVector); +void add10(std::vector> addVector); +void sub10(int* const subVector); +void sub10(std::vector> przeciazenieVector); + +#endif // VECTOROFSHAREDPOINTERS_VECTORFUNCTIONS_HPP