Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // szablon.h
- #pragma once
- template <typename T>
- class Pointer {
- T* ptr;
- public:
- Pointer() : ptr{ nullptr } {}
- Pointer(const T& val) : ptr{ new T{val} } {}
- T getValue() { return *ptr; }
- ~Pointer() {
- if (ptr != nullptr) {
- delete ptr;
- }
- }
- void setValue(T val) {
- if (ptr) {
- *ptr = val;
- }
- else {
- ptr = new T{ val };
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement