473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

.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 1271
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***@community.nospamwrote in message
news:67**********************************@microsof t.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.nospamwrote in message
news:eU**************@TK2MSFTNGP02.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**************@TK2MSFTNGP04.phx.gbl...
"Ben Voigt [C++ MVP]" <rb*@nospam.nospamwrote in message
news:eU**************@TK2MSFTNGP02.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
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...
1
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...
2
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...
2
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
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...
2
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...
7
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...
0
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...
9
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.