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

jiyong wu jiyong.wu at gmail.com
Thu Mar 16 21:45:47 CST 2006


可以考虑一下:在我们的C++实践中,能够这么做带来了什么好处?弊端?不能这么做的时候又当是什么样的一种情况?
不可从理想化/想当然的角度来理解C++,因为C++是被设计为"实用"的语言.

On 3/16/06, Xiao Guo Li <lxgbrian at yahoo.com.cn> wrote:
>
> 大家看看,下面的代码有什么问题没有,
> 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/
> _______________________________________________
> Cpp mailing list
> Cpp at codingnow.com
> http://codingnow.com/mailman/listinfo/cpp
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codingnow.com/pipermail/cpp/attachments/20060316/f46e0f96/attachment.html


More information about the Cpp mailing list