views:

412

answers:

1

The Windows Forms Designer in C++/CLI projects generates both the declarations and definitions of all event handlers in the header file itself. The .cpp it generates is a mere stub which simply includes the generated header and stdafx.h. I feel that I could reduce compile times if I moved the implementation (i.e. definition) of all class methods to the .cpp where they rightfully belong. This becomes especially important when the headers are #included in several places.

Are there any disadvantages or side-effects of splitting my code into separate declaration (.h) and definition (.cpp) files? Suggestions? Best practices?

+1  A: 

If you manually move the initialisation method to the .cpp file (InitializeComponent method), then the designer will not be able to find it when trying to build the design surface and you will loose the ability to use the designer.

I'd recommend leaving InitializeComponent where it is.

Colin Desmond