class Person
{
public:
Person(char* szNewName)
{
// make a copy of the string
m_szName = _strdup(szNewName);
};
~Person() { delete[] m_szName; };
void PrintName()
{
cout << m_szName << endl;
};
private:
char* m_szName;
};
In the above code the _strdup function calls malloc but then the deconstructor calls delete to free up the memory. Can you do this? Mix and match new/delete and malloc/free?
Also, what do the prefix m_ and the suffix _t (not seen in the code above, just curious) on variable names mean?