/
lyapdy
/
skillbox_controllers
Обзор
Документация
Войти
/
lyapdy
/
skillbox_controllers
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
vector3d_project1/include/Vector3D.h
68 строк
2 KB
danillyapunov
task9 commit
13 дек 2025, 16:42
13 дек 2025, 16:42
916f5d0
Код
Авторство
О чём код?
#ifndef VECTOR3D_H #define VECTOR3D_H #include <memory> #include <iostream> class Vector3D { private: std::unique_ptr<double[]> coords; // Динамический массив координат static int objectCount; // Счетчик объектов для демонстрации public: // Конструкторы Vector3D(); Vector3D(double x, double y, double z); // Конструктор копирования Vector3D(const Vector3D& other); // Конструктор перемещения Vector3D(Vector3D&& other) noexcept; // Оператор присваивания копированием Vector3D& operator=(const Vector3D& other); // Оператор присваивания перемещением Vector3D& operator=(Vector3D&& other) noexcept; // Деструктор ~Vector3D(); // Методы доступа double getX() const; double getY() const; double getZ() const; void setX(double x); void setY(double y); void setZ(double z); // Операции с вектором double length() const; void normalize(); Vector3D add(const Vector3D& other) const; Vector3D subtract(const Vector3D& other) const; double dotProduct(const Vector3D& other) const; // Вывод void print() const; static int getObjectCount(); // Операторы Vector3D operator+(const Vector3D& other) const; Vector3D operator-(const Vector3D& other) const; Vector3D& operator+=(const Vector3D& other); Vector3D& operator-=(const Vector3D& other); bool operator==(const Vector3D& other) const; private: void copyFrom(const Vector3D& other); }; // Функции для работы с умными указателями void normalizeVector(std::shared_ptr<Vector3D> vec); void printVectorInfo(std::shared_ptr<Vector3D> vec); std::shared_ptr<Vector3D> createSharedVector(double x, double y, double z); #endif // VECTOR3D_H