473,799 Members | 3,148 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
15 1223
Arnaud Debaene wrote:
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?


I don't think so.

OTOH, if you're worried about build times, you're probably building
something big. And if you're building something big, you're worried about
having a solid, maintainable design (right?). In which case, your WinForms
classes shouldn't have much "meat" in them - they should just be a GUI
veneer over the real guts of your application (model-view anyone?), so the
bulk of your code can still be implemented in The One True Style of
splitting interface into header files and implementation into implementation
files.

Of course, YMMV - mine always does :)

-cd
Nov 17 '05 #11

Carl Daniel [VC++ MVP] wrote:
Arnaud Debaene wrote:
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?


I don't think so.

OTOH, if you're worried about build times, you're probably building
something big. And if you're building something big, you're worried

about having a solid, maintainable design (right?). In which case, your WinForms classes shouldn't have much "meat" in them - they should just be a GUI veneer


The problem is not the size of the code in the header : it is in how
many translation units is this header #included and how often it is
changed (and when finishing the GUI, it changes a lot...)

Arnaud
MVP - VC

Nov 17 '05 #12
Tamas Demjen wrote:
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.


Hi Tom,

This will not be possible for the Whidbey release, the basic
architecture for the designers assumes headerless programming model. For
future releases we are looking into supporting a more traditional (at
least for non template code) C++ model.

Ronald Laeremans
Visual C++ team
Nov 17 '05 #13
Thanks. It's odd, because in both VC++ 2003 and 2005 Beta 1, when I
manually move the InitializeCompo nent function to the .cpp file, the
designer is still working OK, as far as I can tell. I don't know what
kind of problems we may run into with this in the long run, though. So
it's officially not supported, it's good to know.

Tom
Hi Tom,

This will not be possible for the Whidbey release, the basic
architecture for the designers assumes headerless programming model. For
future releases we are looking into supporting a more traditional (at
least for non template code) C++ model.

Ronald Laeremans
Visual C++ team

Nov 17 '05 #14
I find that in vc++ 2003 having all the implimentation code in the header is
a head ache, if i need to define class A which has a method that uses class B
and Class B has a member of Class A you are dead unless you have
implimentation code file. If ms is not going to change this every thing in
the header desing in Whidbey then the new compiler needs to handle the above
case like c# and vb.net.

"Tamas Demjen" wrote:
Thanks. It's odd, because in both VC++ 2003 and 2005 Beta 1, when I
manually move the InitializeCompo nent function to the .cpp file, the
designer is still working OK, as far as I can tell. I don't know what
kind of problems we may run into with this in the long run, though. So
it's officially not supported, it's good to know.

Tom
Hi Tom,

This will not be possible for the Whidbey release, the basic
architecture for the designers assumes headerless programming model. For
future releases we are looking into supporting a more traditional (at
least for non template code) C++ model.

Ronald Laeremans
Visual C++ team

Nov 17 '05 #15
Aaron,

I've been trying to figure this one out for a while and I'm stumped. I have
a class which has a member object (child class), but in the child class I
want to access a function from the parent form. When I add the cross
referencing headers I get compile errors. Are you saying that if I split up
the .h and .cpp files I will be able to achieve this? I appreciate any help.
It's driving me crazy. Basically, having a form as a member of another form.
But the smaller child form wants to either call a function in the parent form.

"Aaron Fischer" wrote:
I find that in vc++ 2003 having all the implimentation code in the header is
a head ache, if i need to define class A which has a method that uses class B
and Class B has a member of Class A you are dead unless you have
implimentation code file. If ms is not going to change this every thing in
the header desing in Whidbey then the new compiler needs to handle the above
case like c# and vb.net.

"Tamas Demjen" wrote:
Thanks. It's odd, because in both VC++ 2003 and 2005 Beta 1, when I
manually move the InitializeCompo nent function to the .cpp file, the
designer is still working OK, as far as I can tell. I don't know what
kind of problems we may run into with this in the long run, though. So
it's officially not supported, it's good to know.

Tom
Hi Tom,

This will not be possible for the Whidbey release, the basic
architecture for the designers assumes headerless programming model. For
future releases we are looking into supporting a more traditional (at
least for non template code) C++ model.

Ronald Laeremans
Visual C++ team

Nov 17 '05 #16

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
2528
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
4742
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
9882
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
1827
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
2411
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
9544
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
10490
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...
0
10259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10238
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,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
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.