Declare the same non-member function twice?

I have class A and class B

I define a non member method using A and B

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

Is it good to declare this in Ah and Bh at the same time, since it can be considered to belong to both A and B?

+4
source share
1 answer

Is it good to declare this in Ah and Bh at the same time, since it can be considered to belong to both A and B?

It can be declared like this because it is just an announcement, not a definition. Other than that, it's probably just a personal taste to do this, or put it in a general heading, etc.

+1
source

Source: https://habr.com/ru/post/1535146/


All Articles