比较/复制 COORD 结构;超载
这看起来微不足道,但无休止的搜索并没有给出答案。
我需要比较和分配。
如果无法添加成员函数或友元函数,如何重载 COORD?
使用这种基于 Windows 的结构只是不好的风格吗?
另外,我知道我可以编写自己的类(或者只为每个成员执行一次操作),但这个问题确实让我想知道。
This seems trivial yet endless searching doesn't yield an answer.
I need to compare and assign.
How can I overload the COORD if I can't add a member function or friend a function?
is it just bad style to use this windows based structure?
Also, I know I can write my own class(or just do the operation once for each member), but this problem just really has me wondering.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
COORD
仅具有公共成员,因此不需要友元函数 - 自由运算符就足够了:COORD
有隐式复制 c'tor 和operator= 已经,不需要定义那些。
COORD
only has public members, so there's no need for friend functions -- free operators should suffice:COORD
has an implicit copy c'tor andoperator=
already, no need to define those.为什么不从
public COORD
派生您的 on 类并添加所需的语句? C++ 中的struct
与class
相同,只是默认情况下所有成员都是public
。Why not derive your on class from
public COORD
and add the required statements?struct
in C++ is just the same asclass
, except that by default all members arepublic
.