In base it should be:Code:3. What are the errors in this C++ code fragment ? Consider both errors that would prevent succesful compilation and errors that would lead to unexpected behaviour when using these classes. class base { base() {m_pData = new Data[100];} ~base() { delete m_pData;} private: Data* m_pData; } class derived : public base { public: derived() {m_iCount = 7; m_pDerivedData = new Data();} ~derived() { delete m_pDerivedData;} private: int m_iCount; Data* m_pDerivedData; };
using delete instead of delete [] in this case may lead to unexpected behaviour.Code:~base() { delete [] m_pData;}
Furthermore, base constructors and destructors should be public, and the destructor virtual.
Most of your questions are too vague to be answered (as the 5th for example).




Marius Bancila
Reply With Quote