Calling wow results in a temporary object, r-value. R values cannot be assigned to non-constant references. Since your copy constructor accepts non-constant references, you cannot directly pass the result of a wow call. This is why adding const fixes the problem. Now the copy constructor accepts references to const, whose r-values correspond only to a fine.
Most likely, your copy constructor does not change the object that it copies, so the parameter should be passed using const-reference. This is how copy constructors work, except in specific documented circumstances.
But, as sbi points out in his answer, this copy constructor should not be called at all. Therefore, although this is all the case, it probably has nothing to do with your problem. If there is no compiler error. Perhaps your compiler sees a two-stage construction and decided that it cuts out the average person by converting A stick; stick = wow(); A stick; stick = wow(); in A stick = wow(); . But this will be a mistake, as evidenced by the fact that it creates a compilation error from a completely legal code. But without real code it is impossible to say what is really happening. There must be several other errors before having problems with your copy constructor.
source share