Function Bodies in Header File

G

Guest

Hi,

In a C++/CLR Windows Forms app I notice that there is only a header and no
..cpp for the form. Also event handler bodies are added by the IDE right to
the header.

What is the philosophy on this?

1. Are C++ and/or C++/CLR classes now intended to be typically implemented
in the header?

2. Is this only for GUI and related?

3. Will functions be inlined by default?

4. Any issues with using a header for derived classes? What about exposing
potential IP functionality beyond just prototypes? Is the idea that for C++
with .NET that assembly references/namespaces will be used to expose class
members to clients i.e. headers no longer the primary means of class member
exposure for C++ using .NET Framework?

5. Any recommendations about function bodies in headers?

Thank You
 
C

Carl Daniel [VC++ MVP]

Greg said:
Hi,

In a C++/CLR Windows Forms app I notice that there is only a header
and no .cpp for the form. Also event handler bodies are added by the
IDE right to the header.

What is the philosophy on this?

1. Are C++ and/or C++/CLR classes now intended to be typically
implemented in the header?

When created by the wizards, yes. The wizards were designed for C# and VB
and can't handle the header/implementation model typically used for C++.
2. Is this only for GUI and related?

You can use it for any classes you wish, but it's typically only found in
wizard-generated classes.
3. Will functions be inlined by default?
Yes.


4. Any issues with using a header for derived classes? What about
exposing potential IP functionality beyond just prototypes? Is the
idea that for C++ with .NET that assembly references/namespaces will
be used to expose class members to clients i.e. headers no longer the
primary means of class member exposure for C++ using .NET Framework?
Yes.


5. Any recommendations about function bodies in headers?

Leave the bodies of wizard generated classes in the headers. On your own
classes, use whatever style you prefer.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top