I've learned what is an initialization list and how to use it but I still was wondering a thing.
What is the difference, if there is, between initializing variables of the class by using an initialization list or doing it by yourself in the constructor?
E.g.
class MyClass {
public:
MyClass() : m_classID(-1), m_userdata(0) {
}
int m_classID;
void *m_userdata;
};
VS
class MyClass {
public:
MyClass(){
m_classID = -1;
m_userdata = 0;
}
int m_classID;
void *m_userdata;
};
Is it just a designing habit which makes code easier to read and write or is there some other specific reason?