Using new(this)will be reconstructed member variables. This can lead to undefined behavior, as they are not destroyed in the first place. The usual pattern is to use a helper function:
class Object {
private:
void init(int, char *);
public:
Object();
Object(int, char *);
};
Object::Object() {
init(0, NULL);
}
Object::Object(int x, char *y) {
init(x, y);
}
void Object::init(int x, char *y) {
}
source
share