SimpleWindow
载入中...
搜索中...
未找到
Point.h
1#pragma once
2
3#include "IComparable.h"
4#include "IToString.h"
5#include <Windows.h>
6#include <string>
7#include <type_traits>
8
9namespace sw
10{
14 struct Point : public IToString<Point>,
15 public IEqualityComparable<Point> {
19 double x;
20
24 double y;
25
29 Point() = default;
30
34 Point(double x, double y);
35
39 Point(const POINT &point);
40
44 operator POINT() const;
45
49 bool Equals(const Point &other) const;
50
54 std::wstring ToString() const;
55 };
56
57 // Point应为POD类型
58 static_assert(
59 std::is_trivial<Point>::value && std::is_standard_layout<Point>::value,
60 "Point should be a POD type.");
61}
相等性比较接口
Definition IComparable.h:14
为支持ToString方法的类提供统一接口
Definition IToString.h:13
表示相对于左上角的点坐标
Definition Point.h:15
Point(const POINT &point)
从POINT构造Point结构体
double y
纵坐标
Definition Point.h:24
std::wstring ToString() const
获取描述当前对象的字符串
Point()=default
默认构造函数
bool Equals(const Point &other) const
判断两个Point是否相等
Point(double x, double y)
构造指定xy值的Point结构体
double x
横坐标
Definition Point.h:19