Where should I put initialization lists?
In header files? cpp files? both?
Thanks
Where should I put initialization lists?
In header files? cpp files? both?
Thanks
This is related to "should I define member functions inline in the class definition?" and I think the answer is the same: it depends on the situation. If the constructor is going to do no work beyond initialising a few member variables, I tend to define the constructor inline, and thus I would have an initialisation list in the header. If not, I tend to define the constructor in a separate source file, in which case the initialisation list would be in the source file. However, you cannot do both simultaneously (i.e., the one definition rule).
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Ah I see. Thank you!