Several places that are easier in C ++

zhaozj2021-02-08  342

#define new creteObject

Many people think that this sentence will cause the identifier New's redefine error. In fact, as long as CreateObject is defined, the definition and use of this statement will not have problems.

Class A



A (void) {m = 0;}

A (Const A & O): M (O.N) {}

A & Operator = (const A & o) {m = .n;}


Int m;


A b;

A a = b;

Many people mistakenly think that this sentence will call a constructor, then call = operator, but in fact it will only call a copy construct of a time. Maybe you have to ask why, try to do this, if the compiler does not do this, and you don't have a standard constructor for a written standard, this sentence?


New Post(0)