Programming with Microsoft Visual C++.NET 6ed [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Programming with Microsoft Visual C++.NET 6ed [Electronic resources] - نسخه متنی

George Shepherd, David Kruglinski

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید


Why Use C++?


You saw in the last chapter that .NET introduces the notion of IL. As long you use a syntax for which there is an IL compiler, youre good to go in the .NET arena. The introduction of IL means that a multiplicity of programming syntaxes can coexist easily on the same platform. Of course, well see in this chapter that C++ is a perfectly decent way to write code for .NET. However, you have other choices as well. Youve no doubt heard of something called C#. C# is a curly-brace-oriented syntax that offers the conciseness of C++ and the convenience of the nonpointer syntax of Visual Basic. Visual Basic is also a perfectly good way to write .NET software. With such an abundance of syntax choices, why would you ever decide to write .NET software in C++? There are actually a number of reasons, as well see here.

Well see Managed Extensions for C++ up close in a minute. From far away, theyre mostly special declarations and keywords that tell the compiler to emit IL instead of native code. Heres why you might want to use Managed Extensions for C++:



    To move unmanaged C++ applications to the .NET Framework ASAP Most highest-performing Windows-based applications these days are written in C++—and its all unmanaged C++. Managed Extensions for C++ are easy to type into your code using the keyboard, and they provide a seamless transition to the .NET Framework. Unmanaged and managed code can easily exist in the same application—even in the same file. Once you have the application running under .NET, you can take your time to reimplement the code to take advantage of the .NET Framework. Another option is to keep your code running as normal unmanaged C++ and use managed wrappers to make your C++ code callable from common language runtime code.

    To access .NET classes from unmanaged code With Managed Extensions, you can directly create, and call, a .NET Framework class from your C++ code. You can also write C++ code that treats a .NET Framework component like any other managed C++ class.

    To access a C++ component from a common language runtime– compatible language Managed Extensions support calling a C++ class from any .NET Framework–compatible language. This is made possible by writing a simple wrapper class using Managed Extensions that exposes your C++ class and methods as a managed class. The wrapper is a fully managed class and can be called from any .NET Framework–compatible language. The wrapper class acts as a mapping layer between the managed class and the unmanaged C++ class—it simply passes method calls directly into the unmanaged class. Managed Extensions support calls to any unmanaged DLL or library, as well as unmanaged classes.

    To access common language runtime code from COM C++ is also useful for calling common language runtime code from COM components. You can use either the unmanaged COM support or the Managed Extensions to access common language runtime components.

    To use managed and unmanaged code in one executable file The Visual C++ .NET compiler translates data, pointers, exceptions, and instruction flow between managed and unmanaged contexts automatically and transparently. This process allows managed code to interoperate seamlessly with unmanaged C++ code.


Managed Extensions for C++ are quite flexible, and you can apply them in many ways. For example, you can apply managed extensions on an element-by-element basis (such as a class-by-class basis).

/ 319