473,809 Members | 2,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET (managed code) confusion

I am curious as to why this code works:

Form2 ^OC = gcnew Form2();
OC->Text = "Child";
OC->MdiParent = this;
OC->Show();

and this does not:

Form2 *OC = new Form2();
OC->Text = "Child";
OC->MdiParent = this;
OC->Show();
I have looked through all my .NET books about managed code and I can not
find any reference to using gcnew or the '^' which appears to be a
pointer notation. I am using the new Visual Studio 2005 if that
matters. I was wondering if someone could clear up my confusion.

Z.K.
Jul 1 '07 #1
4 1287
Z.K. wrote:
I am curious as to why this code works:

Form2 ^OC = gcnew Form2();
OC->Text = "Child";
OC->MdiParent = this;
OC->Show();
The above is the new C++/CLI syntax (default in VC++ 2005)
and this does not:

Form2 *OC = new Form2();
OC->Text = "Child";
OC->MdiParent = this;
OC->Show();
This is the old managed C++ syntax of VC++ 2003

--
SvenC
Jul 1 '07 #2

"SvenC" <Sv***@communit y.nospamwrote in message
news:67******** *************** ***********@mic rosoft.com...
Z.K. wrote:
>I am curious as to why this code works:

Form2 ^OC = gcnew Form2();
OC->Text = "Child";
OC->MdiParent = this;
OC->Show();

The above is the new C++/CLI syntax (default in VC++ 2005)
>and this does not:

Form2 *OC = new Form2();
OC->Text = "Child";
OC->MdiParent = this;
OC->Show();

This is the old managed C++ syntax of VC++ 2003
Which had all kinds of problems, including silently passing unpinned
pointers to native code and startup deadlock.

Use the C++/CLI syntax exclusively.

A lot of authors, caring about profit and not correctness, were racing to
get their books out first and didn't care to mention all the reasons Managed
Extensions shouldn't be used. They couldn't have had a good understanding
of the material. Anyone who tried to sell a "Managed C++" book using VC2003
instead of an article "Why Managed C++ isn't ready for the real-world" is a
profiteer, not a programmer, and you shouldn't buy any books by that author
ever again.

C++/CLI has finally existed long enough for some published books to be
available. I don't have it myself, but Nish's book is probably quite good
http://voidnish.com/NishBooks.aspx. He's another MVP and seems to know his
stuff.
Jul 2 '07 #3
"Ben Voigt [C++ MVP]" <rb*@nospam.nos pamwrote in message
news:eU******** ******@TK2MSFTN GP02.phx.gbl...
Anyone who tried to sell a "Managed C++" book using VC2003 instead of an
article "Why Managed C++ isn't ready for the real-world" is a profiteer,
not a programmer, and you shouldn't buy any books by that author ever
again.
You mean like Siva Challa and Artur Laksberg - both on the compiler team at
MS - who wrote this one?:

http://www.amazon.com/Essential-Guid.../dp/1893115283

Theirs is a _good_ book.

While it is true that the language had problems, four years ago it was just
about the only option if one needed to straddle the fence between managed
and native development with C++.

C++/CLI is better to be sure but MC++ is far from unusable.

Regards,
Will
Jul 2 '07 #4

"William DePalo [MVP VC++]" <wi***********@ mvps.orgwrote in message
news:e7******** ******@TK2MSFTN GP04.phx.gbl...
"Ben Voigt [C++ MVP]" <rb*@nospam.nos pamwrote in message
news:eU******** ******@TK2MSFTN GP02.phx.gbl...
>Anyone who tried to sell a "Managed C++" book using VC2003 instead of an
article "Why Managed C++ isn't ready for the real-world" is a profiteer,
not a programmer, and you shouldn't buy any books by that author ever
again.

You mean like Siva Challa and Artur Laksberg - both on the compiler team
at MS - who wrote this one?:

http://www.amazon.com/Essential-Guid.../dp/1893115283

Theirs is a _good_ book.
Did they also clearly state the problems with the implementation? If not,
then it fails to meet my requirements.

Jul 5 '07 #5

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

Similar topics

2
7305
by: asanford | last post by:
We use StackWalk(StackWalk64) from dbghelp.dll to walk our callstacksas needed, using the various Sym* methods (SymGetSymFromAddr, SymGetLineFromAddr) to resolve source file, function name, and source line number for each frame. This works fine for unmanaged code, but when we have a call stack that goes into or through some managed code, we cannot resolve any info for the managed frames - we can however, get all the information for the...
1
1814
by: Dr Evil | last post by:
There seems to be a bug in managed VC++ when a class is named 'Object'. The code following demonstrates the problem. Note that if the class named 'Object' is renamed ( and references to it changed appropriately ) it compiles ok. It makes no difference if class Object is fully qualified with the namespace, or if it's put in its own namespace ( outside of AccountManager ) and fully qualified to that one. Also, if the AccountManager class is...
2
1895
by: bor_kev | last post by:
Hi, First of all, i want to use the new managed class syntax and STL.NET under Microsoft Visual (C++) Studio 2005 Beta. I read in a Microsoft article(http://msdn.microsoft.com/VISUALC/default.aspx?pull=/library/en-us/dnvs05/html/stl-netprimer.asp) that i am suposed to include : #include <cli/vector> #include <algorithm>
2
2731
by: Sandy | last post by:
I am confused about Unmanaged Code, How .Net Framework treate that code, What is the use of that. Thanks in advance Sandeep Chitode
6
3369
by: guxu | last post by:
I have a managed C++ code which calls some methods in unmanaged C++ DLL. In my unmanaged DLL, I have a PROTECTED virutal function in a base class and derived class has a PRIVATE function which overrides the virutal one in the base. In my managed class, I have the following private: CUnmanaged __nogc* m_pUnManaged
2
1271
by: Ian | last post by:
1. I want to be use mix unmanaged code with managed code. In particular, the unmanaged code uses MFC CFile to perform file I/O. Can CFile be used in unmanaged code that is mixes with managed code? I've tried this but keep getting a system::exception is thrown with the message "External component has thrown an exception" when the CFile instance is created. 2. How does the assignment operator check to see that the source and...
7
2677
by: Alex Y Wang | last post by:
Hi all, my current project is completely written in native C++, and for some reason I need to write a standalone .Net program to do some work for it. Therefore, I need to find an effective way of IPC between my unmanaged code and managed code. What's most appropriate IPC solution for this? Thanks in advance. Alex Y Wang
0
1004
by: manyuaditya | last post by:
Hi, I'm developing this scientific application that does the following- 1. read a data table ( 100's of millions of rows ) 2. Create a tree out of this data ( a kd-tree which is sort of like a binary search tree but over multiple dimensions ) 3. store this tree in a database table Part2
9
3568
by: =?Utf-8?B?RWR3YXJkUw==?= | last post by:
I would greatly appreciate some help on passing managed object into unmanaged code. I need to pass a reference (address of) of a managed class into unmanaged code (written by a thrid party). The 3rd party unmanaged DLL will pass this reference into standard Win32 unmanaged static callback function in my code. Inside this unmanaged callback function I need to cast this unmnaged pointer that I have received from 3rd party back into the...
0
9722
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
9603
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
10643
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
10378
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...
0
10121
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
9200
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...
1
7664
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...
1
4333
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
3862
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.