First of all thank you very much for your clues.
I'm having a particular problem while trying to finish an assignment. I'm pretty sure is something wrong with namespaces, includes, header files and all this stuff, but don't really know what's going wrong.
The point is this: I need two different classes (let's say Car and CarShop), which each of them has to overload the operator +.
Car->Car &operator+(const Car &c)(should "add" two cars)CarShop->CarShop &operator+(const Car &c)(should "add" a car to an existing CarShop)
In file CarShop.h, I need to #include "car.h", since it works a lot with different "car" objects. Moreover, in my main test class, let's say main.cpp, I also need to #include "car.h" and #include "carshop.h".
Here I get the error message. Visual Studio (we're working with it as our IDE) gives me "LNK1169 & LNK2005" errors, explaining that "one or more symbols are simultaneally defined".
Anyone could help me please? What should I do in order to avoid this conflict between the two overloaded operators?
PS. Both of them (the 2 overloaded operators) are declared as friend functions for their respective classes (in the .h files), and implemented in their respective .cpp file.
operator+should return by value, not by reference, if it follows the behavior of the built-in+: it should not mutate either of its operands and should return a new object. If you want to mutate one of the operands, you should consider usingoperator+=.#defineguards?