加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 两次声明相同的非成员函数?

发布时间:2020-12-16 07:08:24 所属栏目:百科 来源:网络整理
导读:我有A级和B级 我使用A和B定义非成员方法 double operator*(const A a,const B b); 将它同时声明为A.h和B.h是否合适,因为它可以被认为属于A和B两者? 解决方法 Is it good to declare this into A.h and B.h at the same time since it can be considered as
我有A级和B级

我使用A和B定义非成员方法

double operator*(const A& a,const B& b);

将它同时声明为A.h和B.h是否合适,因为它可以被认为属于A和B两者?

解决方法

Is it good to declare this into A.h and B.h at the same time since it can be considered as belong to both A and B?

可以这样声明它,因为它只是声明,而不是定义.除此之外,可能只是个人品味,是否这样做,或将其放入一个共同的标题,等等.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读