在c++ 的构造函数中调用自身的其他够咱函数 需要在够咱函数中使用 new(this) 直接调用会出现问题。
//A.h
#ifndef _A_H_
#define _A_H_
#include <stdio.h>
#include <new>
class A
{
public:
A()
{
printf("In A::(). m_x=%d\n", m_x);
new(this) A(0);
printf("Out A::(). m_x=%d\n", m_x);
}
A(int x)
{
printf("In A::(int x). x=%d\n", x);
m_x=x;
}
private:
int m_x;
};
#endif