Click to See Complete Forum and Search --> : Why is the function body in the .h header file?


frog_jr
April 23rd, 2005, 01:56 PM
This is probably a common question, but I have not found an answer to it.

I'm using ms Visual C++ .NET (standard) for some personal projects...

When I double click on an event in a properties view of a form component (e.g. a button Click event, or a textbox TextChanged event) I am presented with a funciton body in the .h file for the form into which I can place the code for the event.

I "expected" that the function body would be placed in the .cpp file.

Am I missing something, or is there a configuration I have missed?

lior6543
April 24th, 2005, 06:44 PM
I would like to join you & ask the same question: WHY???????????

JimG
April 26th, 2005, 01:54 PM
Poor design.

http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-vc/3925/C-Code-in-header-files

frog_jr
May 4th, 2005, 03:38 PM
OK then,

From some of you that are veteran VC++.NET coders how do you handle this?

A) Leave the definition in the .h file (with the declaration)
B) Move the definition to the .cpp file

Maybe I ought to post this as a poll!

What are advantages/disadvantages to each of these?

lloydy
May 11th, 2005, 01:54 AM
Leave it in the .h file.

I actually like it. It means I can change my code, without having to always keep function definitions the same in the two files.