我有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?
可以这样声明,因为它只是声明,而不是定义。除此之外,是否这样做,或者将其放入公共(public)标题等可能只是个人喜好。
关于c++ - 两次声明相同的非成员函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22878399/