473,786 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where do I put the code for managed classes in managed C++

Hey everyone,

I noticed that unlike C#, managed C++ still uses headers and implementation
files. My question is, is there any consensus of where to put the
implementation of the managed class?

In my project, I put everything in the header file. I don't see the need to
put it in a seperate implementation file.

Any thoughts?

Thanks,
--
Tom Tempelaere.
Nov 17 '05 #1
15 1222

"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThot mailD.Tcom|/\|@P$0_|\|_>
wrote in message news:29******** *************** ***********@mic rosoft.com...
Hey everyone,

I noticed that unlike C#, managed C++ still uses headers and
implementation
files. My question is, is there any consensus of where to put the
implementation of the managed class?

In my project, I put everything in the header file. I don't see the need
to
put it in a seperate implementation file.

Any thoughts?


It's just a question of style.

Putting all your member definitions in the header file makes them implicitly
inline, but given that most inlining is done by the JIT and happens
regardless of whether the function was marked as inline, it's not clear that
that's really a significant factor.

It's likely the case that putting all the implementation in the header file
will result in slower build times as the project gets larger - that's one
advantage the old header file/implementation file technique still has over
the C#/Java all in one file model.

-cd
Nov 17 '05 #2
"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThot mailD.Tcom|/\|@P$0_|\|_>
wrote in message news:29******** *************** ***********@mic rosoft.com...
In my project, I put everything in the header file. I don't see the need
to
put it in a seperate implementation file.


It's not something that I use, but I _think_ that WinForms puts code in
headers too. So, if you want a precedent, and one from inside the big house,
there you go. :-)

Now I know that the language allows it, and the distinction between source
and header that was so clear to me in the K&R days is not so black and white
in modern C++, but it looks a tad strange to me. Just my opinion ...

Regards,
Will
Nov 17 '05 #3
Hi Carl,

"Carl Daniel [VC++ MVP]" wrote:
"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThot mailD.Tcom|/\|@P$0_|\|_>
wrote in message news:29******** *************** ***********@mic rosoft.com...
Hey everyone,

I noticed that unlike C#, managed C++ still uses headers and
implementation
files. My question is, is there any consensus of where to put the
implementation of the managed class?

In my project, I put everything in the header file. I don't see the need
to
put it in a seperate implementation file.

Any thoughts?
It's just a question of style.

Putting all your member definitions in the header file makes them implicitly
inline, but given that most inlining is done by the JIT and happens
regardless of whether the function was marked as inline, it's not clear that
that's really a significant factor.


I see. But, since all methods are exported because it is a library (in my
project it is), I don't think it really matters anymore.
It's likely the case that putting all the implementation in the header file
will result in slower build times as the project gets larger - that's one
advantage the old header file/implementation file technique still has over
the C#/Java all in one file model.


Tom.
Nov 17 '05 #4
Hi William,

"William DePalo [MVP VC++]" wrote:
"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThot mailD.Tcom|/\|@P$0_|\|_>
wrote in message news:29******** *************** ***********@mic rosoft.com...
In my project, I put everything in the header file. I don't see the need
to
put it in a seperate implementation file.
It's not something that I use, but I _think_ that WinForms puts code in
headers too. So, if you want a precedent, and one from inside the big house,
there you go. :-)


YES! :D
Now I know that the language allows it, and the distinction between source
and header that was so clear to me in the K&R days is not so black and white
in modern C++, but it looks a tad strange to me. Just my opinion ...


Well, since I'm used to coding .NET in C#, I kind of dislike going back to
the header/implementation model. But managed C++ is probably more than just
C# so the model is probably still useful. I think I will be convinced once I
start mixing managed and unmanaged code. This is the actual purpose of my
project in managed C++: use of unmanaged C++-libraries under the hood.

BTW: Do we have a shorter name/tag for managed C++, like MC++ or so?

Thanks,
Tom Tempelaere.
Nov 17 '05 #5

"William DePalo [MVP VC++]" <wi***********@ mvps.org> wrote in message
news:OR******** ******@TK2MSFTN GP12.phx.gbl...

It's not something that I use, but I _think_ that WinForms puts code in
headers too. So, if you want a precedent, and one from inside the big
house, there you go. :-)

Now I know that the language allows it, and the distinction between source
and header that was so clear to me in the K&R days is not so black and
white in modern C++, but it looks a tad strange to me. Just my opinion
...

Regards,
Will


You're correct. That's exactly where the implementing code is placed in a
..NET Windows Form project, much to the displeasure of purists (some of whom
have been very vocal about it).
AAMF, it remains that way in the VS 2005 beta, so it looks not to be a
temporary thing, but possibly a new trend coming from the "big house".

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 17 '05 #6
"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThot mailD.Tcom|/\|@P$0_|\|_>
wrote in message news:36******** *************** ***********@mic rosoft.com...
BTW: Do we have a shorter name/tag for managed C++, like MC++ or so?


Yes, at least in this group MC++ stands for "Managed Extensions for C++" or
just "managed C++".

That's the good news. The bad news is that the .Net targetting dialect (my
word) of C++ is getting a new name to go with new syntax in VS.Net 2005.
It's short name is usually written as C++/CLI.

Just by the way, at some point in the future C++/CLI will be an ECMA
standardized language and sometime before we all retire <g> it should be
standardized by ISO as well.

Regards,
Will
..
Nov 17 '05 #7
"Peter van der Goes" <p_**********@t oadstool.u> wrote in message
news:eF******** *****@TK2MSFTNG P14.phx.gbl...
You're correct. That's exactly where the implementing code is placed in a
.NET Windows Form project, much to the displeasure of purists (some of
whom have been very vocal about it).


Count me in that group. Or in the "dinosaurs" group of people who learned
_the man's_ language from the famous tome by K&R with the white cover and
the big blue C. :-)

Regards,
Will
Nov 17 '05 #8
Peter van der Goes wrote:
You're correct. That's exactly where the implementing code is placed
in a .NET Windows Form project, much to the displeasure of purists
(some of whom have been very vocal about it).
AAMF, it remains that way in the VS 2005 beta, so it looks not to be a
temporary thing, but possibly a new trend coming from the "big house".


Then there is something I don't understand : I believed that part of the
"C++ come back" in VS2005 was due to the fact that MS realized that the
compilation model of C# and VB.NET didn't scale well, and that the
header/implementation separation was still the only way to keep build time
to grow exponentially on large projects. I am totally wrong here?

Arnaud
MVP - VC
Nov 17 '05 #9
> You're correct. That's exactly where the implementing code is placed in a
.NET Windows Form project, much to the displeasure of purists (some of whom
have been very vocal about it).


Nothing prevents you from manually cut and pasting those event handlers
to the .cpp file, though. The form designer will still be working.
However, you might get into trouble in the long run, like if you double
click on an event in the designer. I would certainly prefer if the final
release had the option of putting the event handlers to the .cpp file.
At least it should tolarete if we do that manually.

Tom
Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4319
by: CodeTyro | last post by:
My native language being C++, I've got a few questions that a couple of hours of searching on msdn didn't answer. First, when using unsafe code and pointers, what is the C# equivalent to the C++ "delete" command? I would like to keep my memoryspace clean, but I've been unable to find a way to do it thus far. Second, I'm using structs to store a specific set of data. Is there a C# equivalent to the C++ STL "Vector" (or any of the...
4
2526
by: 0to60 | last post by:
I'm trying to create a .dll with VS.NET 2003 Architect that contains a math computational component. I need the guts of the thing to be in native code, as performance is key for that part. But, I need a .net wrapper because this "calculator" is actually a component used by an enterprise app written entirely in .net. What I want to do is have one project. I've created an MC++ .dll project. Its got a __gc class (the wrapper) and a...
2
4741
by: Steven Cool | last post by:
Hi, DA PROBLEM: Once I wrote a c++ dll. I wanted to use that dll in my new c# project, so I compiled it with the CLR option. The compilation was ok. Like I said, I wanted to use the dll (with several classes in it), in my c# project. I added the reference to my c# project. But still I can't use the classes. Do I need to use Dllimport?. When I look at the object browser, i can see all the classes but there
4
9880
by: Tim Menninger | last post by:
Just started working on this and have not found any real good resources out there. We have a lot of native C++ Dll code that we use for our app. We want to share the code so that C# ASP.net code can use the same business logic as our C++ client. Here are some questions: 1) Is there a way to call into native C++ classes directly? Meaning we do not have C API. I believe we could use a C API using the in C#. 2) If can't do #1, do we need...
4
1453
by: quortex | last post by:
Hi, I have created a very small test wrapper class in Managed C++ which wraps up some very simple native code. I am using C# 2 + Visual Studio 2005 Beta 2. I have the back end C++ library without CLR which is to be wrapped that outputs fine to a static .lib as expected. Then I import the .lib into a Managed C++ DLL (/CLR) and wrap it up in
1
1135
by: bonk | last post by:
Hello, I am trying to create a c++ dll or lib (not COM) that contains a little bit of managed code and a lot of unmanged code using c++/CLI. Basically some classes rely on managed bits internally. But nothing of that managed stuff will be exposed to the outside. The user of that dll is suppsed to "see" only plain unmanaged c++ classes so that if he uses that dll he does not have to compile his code using that /CLR switch. Do you think...
11
1826
by: Peter Oliphant | last post by:
Is there any plan to support templates with managed code in the (near) future? For instance, VS.NET 2005... : )
8
1448
by: Ignazio | last post by:
When creating forms with Visual C++ 2005, all the code for building the interface (the InitializeComponent method) and event handlers are set in the ..H file, as they were inline methods. So I ask, for managed code they are effectively inline methods or they are handled indifferently if they are in the class declaration or outside of it? Do I still have to write declarations and definitions in different files for avoiding multiple compiling...
8
2410
by: Henri.Chinasque | last post by:
Hi all, I am wondering if there are any quick/efficient ways to look at a piece of c++ code and determine if it would run faster if it was compiled to native code. I ask this because all of my c++ is currently compiled with the /clr flag meaning that nothing is compiled native. I've seen some examples where wrapping arithmetically intense code with "pragma unmanaged" results in increased performance, but this was in test code with...
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.