Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "Point.h"
- namespace at {
- template <typename T>
- class Point2D :
- public Point < T > {
- public:
- Point2D<T>() = default;
- Point2D<T>(const T& xt_, const T& yt_) {
- this->xt_ = xt_;
- this->yt_ = yt_;
- }
- Point2D<T>(const Point<T>& other) {
- assign(other);
- }
- ~Point2D<T>() = default;
- virtual void swap(Point<T>& other) override {
- if (this != &other) {
- Point2D<T> temp(*this);
- *this = other;
- other = temp;
- }
- }
- virtual void add(const Point<T>& other) override {
- this->xt_ += other.getX();
- this->yt_ += other.getY();
- }
- virtual void assign(const Point<T>& other) override {
- if (this != &other) {
- this->xt_ = other.getX();
- this->yt_ = other.getY();
- }
- }
- void setZ(const T& zt_) final {
- assert(("Trying to set a Z coordinate from a Point2D", 0));
- }
- const T& getZ() const final {
- assert(("Trying to retrieve a Z coordinate from a Point2D", 0));
- return zt_;
- }
- friend Point2D<T> operator+(Point2D<T> lhs, const Point2D<T>& rhs) {
- return lhs += rhs;
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement