As known, returning local variable from function in C++, is unsafe, due to scoping. In Effective C++ Third Edition, Scott Meyers tells about this problem in item 21, at page 101. However, in conclusion he said, that right decision will be to write:
inline const Rational operator*(const Rational& lhs, const Rational& rhs) {
return Rational(lhs.n * rhs.h, lhs.d * rhs.d);
}
Isn't this also a bad practice, and this function is unsafe?