Constructor delegation from body of constructor
Not sure why but seems some issue to save the new code from playground on windows 10, so pasting code into query itself: class myString { public: myString() : m_pCharName(nullptr), m_intSize(0) { cout << "null contructor called\n"; } ~myString() { cout << "Destructor called\n"; if (m_pCharName) delete[] m_pCharName; } myString(const char* pInput) { if (pInput == nullptr) myString(); else { m_intSize = strlen(pInput); m_pCharName = new char[m_intSize + 1]; strcpy_s(m_pCharName, m_intSize + 1, pInput); } } private: char* m_pCharName; int m_intSize; }; Question is on constructor delegation. Is below line proper? if (pInput == nullptr) myString(); I want to call non parametric constructor in case of input as nullptr.