[cpp] construction fucntion

李慧霸 magazine.lihuiba at 163.com
Wed Mar 28 15:24:47 CST 2007


>class A{
>	int m_a;
>public:
>	//A(){std::cout<< "A()new"; new(this)A(0);}//大概记得这个方法是 TCPL 里面推荐的
>	A(){std::cout<< "A()this->A::A()";this->A::A(0);}
>	A(int a):m_a(a){std::cout<< "A(int)";}
>	int get(){return m_a;}
>};

长见识,关注中。

我以前的办法是把公共的东西抽取到一个private函数中去,呵呵。

------------------				 
李慧霸
2007-03-28






More information about the Cpp mailing list