As a beginner,it's a problem to know the style of Class' struct in Heap.so i don't know.
but we can assume that it's setup by the data which is static or protected and private or public.
so the class copy constructor copy the data struct to the new class object.
now we know if there 's a pointer in this struct problem comes,when copy the data struct, it copies the pointer's address to the new object,when destructor the new object will release the resourse that be shared by the new and old object.
and we should know that constructor and destructor's sequence in class inherit.
the inherit must load the base class and when destructor the sequence is opposite.
all this is cause of priority.
本文探讨了在堆中类的结构风格问题,特别是对于初学者来说如何理解类的数据成员及构造函数和析构函数的执行顺序。文章分析了当类包含指针成员时,在复制构造函数中可能引发的问题,以及继承类中的构造与析构顺序。
7573

被折叠的 条评论
为什么被折叠?



