Where should I put initialization lists?
In header files? cpp files? both?
Thanks
This is a discussion on initialization lists in header files? within the C++ Programming forums, part of the General Programming Boards category; 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).
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
Ah I see. Thank you!