"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.