Solved: 18 - Pointer Basics

This commit is contained in:
2026-08-15 17:20:47 +03:00
parent d9e08afbcb
commit 9676acc893
2 changed files with 18 additions and 5 deletions
@@ -2,7 +2,7 @@
namespace pointers { namespace pointers {
[[nodiscard]] auto get_value(int* ptr) -> int; [[nodiscard]] auto get_value(const int* ptr) -> int;
void set_value(int* ptr, int value); void set_value(int* ptr, int value);
[[nodiscard]] auto is_null(const int* ptr) -> bool; [[nodiscard]] auto is_null(const int* ptr) -> bool;
void swap_via_pointers(int* a, int* b); void swap_via_pointers(int* a, int* b);
@@ -2,9 +2,22 @@
namespace pointers { namespace pointers {
auto get_value(int* ptr) -> int { (void)ptr; return 0; } auto get_value(const int* ptr) -> int {
void set_value(int* ptr, int value) { (void)ptr; (void)value; } return *ptr;
auto is_null(const int* ptr) -> bool { (void)ptr; return true; } }
void swap_via_pointers(int* a, int* b) { (void)a; (void)b; }
void set_value(int* ptr, int value) {
*ptr = value;
}
auto is_null(const int* ptr) -> bool {
return ptr == nullptr;
}
void swap_via_pointers(int* a, int* b) {
const auto aux = *a;
*a = *b;
*b = aux;
}
} // namespace pointers } // namespace pointers