I am trying to set this char* to NULL using a default constructor.
But I am facing trouble.
The problem is with the line where I am using a default constructor and setting m_name=NULL;
class Car {
char *m_name;
int m_carnum;
public:
Car() :m_carnum(0), m_name = NULL {} //this line has the error
~Car(){}
};
While this code seems to be working:
Car() :m_carnum(0) {
m_name = NULL;
}
So I why isn't this working ?
m_name = NULL;