What is going on? C++, events, headers and cpp files.

  • Thread starter Thread starter Nicolae Fieraru
  • Start date Start date
N

Nicolae Fieraru

Hi All,

I asked this question a few days ago and nobody answered me so far. I am
using C++ and Visual Studio .Net 2003.
Lets say I create a WindowsForms Application and I add a button to the form.
When I double click on the button, I create an event for click. Then I can
write all the code to deal with that event, and everything works fine. The
only problem I have is that the code is written in the header file, instead
of being placed in the cpp file. I expect that when I add an event, the
function definition should be placed in the header file, and the function
implementation, in the cpp file.
Did I miss a setup option, or is there an option set up wrong? It isn't
normal if all the code gets written in the header file. What is the
procedure, so that when someone adds an event for a component, the event
function to be added to the cpp file?

Regards,
Nicolae
 
Nicolae,

You can still seperate the implementation from the header file. Here is an
snippet from Kate Gregory's VC++ .NET 2003 Kick Start book: "When you work in
unmanaged code, you move as much of the code as you can into an
implementation file to keep the header small, because all the code that uses
the class must include the header file. However, when you work with managed
code, the header file is not included: The reference to the assembly provides
the compiler with the information it needs. So in managed code, it doesn't
matter where you put your method bodies." In C# they only deal with .cs files
and don't worry about header files. Hope this helps.
 
Back
Top