Don’t think anyone will seriously argue against the usefulness of namespace.
It is also mentioned that we can use struct
to simulate the namespace functionality. But it will not be able to support direct, infix call of operator functions.
Don’t think anyone will seriously argue against the usefulness of namespace.
It is also mentioned that we can use struct
to simulate the namespace functionality. But it will not be able to support direct, infix call of operator functions.
Compiler cannot decide:
Some concepts:
member function templates (c++ language construct)
NullClass (useful while you are a caller of the function and want to avoid potential mistake)
Example:
operator*
and operator+
should return a new object instead of a reference. The latter approach will introduce problem such as memory leak
Additional note:
Avoid overloading short-circuiting operators: x || y or x && y. The overloaded versions of these do not short-circuit — they evaluate both operands even if the left-hand operand “determines” the outcome, so that confuses users.
From