|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 hellomyprogram 于 2023-10-6 17:22 编辑
graphics.h
- namespace graph
- {
- template <typename position_type = int>
- class Dot
- {
- public:
- position_type x = 0;
- position_type y = 0;
- };
- class Rect
- {
- enum relative_pos
- {
- TopLeft = 0b0000,
- TopMiddle,
- TopRight,
- MiddleLeft = 0b0100,
- Center,
- MiddleRight,
- BottomLeft = 0b1000,
- BottomMiddle,
- BottomRight
- };
- public:
- Dot<> position = {0, 0};
- unsigned int width;
- unsigned int height;
- Rect(unsigned int, unsigned int);
- Rect(int, int, unsigned int, unsigned int);
- Dot<> get_absolute(relative_pos);
- Dot<> get_absolute(Dot<>);
- void set_absolute(relative_pos, Dot<>);
- Dot<> set_absolute(Dot<>, Dot<>);
- };
- };
复制代码
graphics.cpp
- #include <graphics.h>
- Dot<> graph::Rect::get_absolute(relative_pos relative)
- {}
复制代码
编译器凭什么说 Dot 不是模板
Dot 前面没加 graph 命名空间 |
|