Updated: July 14, 2020 (August 23, 2004)

  Charts & Illustrations

The New C++

My Atlas / Charts & Illustrations

425 wordsTime to read: 3 min

Visual C++ 2005 completely reworks the interaction between C++ and the .NET Common Language Runtime. Specifically, it introduces a “New C++” syntax for managed code that is designed to fix shortcomings of the Managed Extensions to C++ (commonly referred to as Managed C++, or MC++), introduced in 2002 as part of Visual C++ .NET.

Shown here are two code samples that perform the same function, using the older Managed C++ syntax (left) currently supported in Visual C++ 2003 and the New C++ syntax (right) planned for Visual C++ 2005. Both samples define a very simple class that represents a credit account and which has an integer property that represents the account’s credit limit.

As shown in the code sample on the left, Managed C++ uses the ANSI standard method of adding new keywords to the C++ language: all new keywords began with two underscores (__property, for example). The sample illustrates several disadvantages of this approach. First, the presence of leading underscores in the keywords __gc and __property on lines 1, 4, 5, and 10 is unattractive and makes the code hard to read. It is also hard to write: developers complained, as Visual C++ architect Stanley Lippman said, “Particularly after the 2000th time they type __gc.” Second, the credit limit property is not integrated into the language: its definition appears to be two unrelated functions on lines 4 and 5 and setting its value is done by what appears to be a function call on line 11.

Atlas Members have full access

Get access to this and thousands of other unbiased analyses, roadmaps, decision kits, infographics, reference guides, and more, all included with membership. Comprehensive access to the most in-depth and unbiased expertise for Microsoft enterprise decision-making is waiting.

Membership Options

Already have an account? Login Now