[cpp] 问一个关于拷贝构造函数的问题

Xiao Guo Li lxgbrian at yahoo.com.cn
Thu Mar 16 16:36:29 CST 2006


大家看看,下面的代码有什么问题没有,
class Test{
public:
  Test();
  Test(const Test& t);
private:
  char * m_pc;
};

Test::Test(const Test& t): m_pc(t.m_pc)
{
}

...
问题是,这样写没有问题,但按照理解,
m_pc是类Test的私有变量,t.m_pc这种写法是不允许的。

哪位DX给解释一下?




	

	
		
___________________________________________________________ 
雅虎1G免费邮箱百分百防垃圾信 
http://cn.mail.yahoo.com/


More information about the Cpp mailing list