Temporary member variable in stack space cannot be transmitted after the end of the function lifetime
operator* (constconst a& b) { A temp; = A.data*b.data; // Multiply the member variables of a, b return temp;}
Since the stack space is not good, try the heap space
operator* (constconst a& b) { *temp=new A; = A.data*b.data; // Multiply the member variables of a, b return *temp;}
Not, because you may forget yourself new, even if you have not forgotten, but appear ((a*b) *c) Situation will make you cannot delete
operator* (constconst a& b) { staticnew A; = A.data*b.data; // Multiply the member variables of a, b return temp;}
Attempts to derive immortality with global variables, but the presence of if ((a*b) = = (c*d) will be constant
There is no way, pass-by-reference, although good, please don't top, this time we honestly use Pass-by-value
Reading notes _effective_c++_ clause 21: When you must return an object, don't be paranoid about returning it reference