当需要删除向量中的所有指针时,我会 通常做 A * pSomePointer =(*(m_vectorData) .begin()+ nPos)); 删除pSomePointer; 如果使用派生类B创建pSomePointer将是析构函数 B被叫或者是A的析构函数? SimonThanks for that.One last question.When it comes time to delete all the pointers in the vector, I wouldnormally doA *pSomePointer = (*(m_vectorData.begin()+nPos));delete pSomePointer;if pSomePointer was created with the derived class B will the destructor ofB be called or the destructor of A?Simon 这篇关于试图理解从基础到派生的铸造。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 00:44