First, this operator
friend ostream &operator<<(ostream stream, three_cl obj);
incorrect. The std::ostream has a remote copy constructor. Therefore, you cannot pass an object of class std::ostream by value. And besides, from the function declaration, it turns out that the function returns a reference to the local object std::ostream , which leads to undefined program behavior.
Of course, for user-defined types, it is better to pass objects by reference. And functions can be separately overloaded for lvalue links and rvalue links.
Here's how, for example, the push_back function for the std::vector class is overloaded
void push_back(const T& x); void push_back(T&& x);
That is, one function is defined for a constant lvalue reference; the second is for an rvalue reference.
In your example operator operator << also better to declare the second parameter as a constant link. In this case, you can call the operator for temporary objects, since the constant reference can be "attached" to the temporary objects: Yes, and the objects themselves, for which the operator is called, can also be constant.
friend std::ostream & operator <<( std::ostream &stream, const three_cl &obj );
For fundamental types, there is no need to pass objects by constant reference instead of objects by value, if you are not going to write a generic template function. For example, in the C ++ standard, the following operator << for fundamental types are defined as
basic_ostream<charT,traits>& operator<<(bool n); basic_ostream<charT,traits>& operator<<(short n); basic_ostream<charT,traits>& operator<<(unsigned short n); basic_ostream<charT,traits>& operator<<(int n); basic_ostream<charT,traits>& operator<<(unsigned int n); // и другие операторы для фундаментальных типов
As you can see, the arguments are passed by value.
As for the return value, you must take into account that you cannot return a reference from a function to a local object (unless it has a static memory class).
Returning a link allows you to combine calls of several functions in a chain. For example, in the class std::basic_string operator operator += declared as returning a link. Thanks to this you can write, for example,
std::string s( "Hello " ); std::cout << ( ( s += "World" ) += '!' ) << std::endl;
And this is rather a question not in style, but in program efficiency and flexibility. :)