24 lines
362 B
C++
24 lines
362 B
C++
#include "pointer_basics.hpp"
|
|
|
|
namespace pointers {
|
|
|
|
auto get_value(const int* ptr) -> int {
|
|
return *ptr;
|
|
}
|
|
|
|
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
|