Differences Between Visual C and C

Differences Between Visual C++ and C++

C++ is a language, and Visual C++ is a product. The language itself was developed in the early '80s, and C++ compilers have been for sale since about 1985. Visual C++ made its debut in 1993, and has had many major releases since that time. In the late '90s a standard was developed for the C++ language, and the latest release of Visual C++ (in Visual Studio .NET 2003) includes a top- notch C++ compiler that is 98% compliant to that standard, the most compliant version ever.

The Visual C++ Suite of Tools

Of course, Visual C++ is much more than just a compiler. In addition to a compiler, Visual C++ includes

  • Two very powerful C++-only class libraries (MFC and ATL).

  • An implementation of the Standard Template Library, STL, part of standard C++.

  • A debugger that includes a variety of productivity- boosting features to help you understand what your application is doing, and why.

  • An integrated development environment that enables you to edit, compile, and debug your code all from the same application.

  • A suite of wizards and designers that generates code for common application types, or simplifies coding by using dialog boxes like the properties window to automatically modify your code.

  • The .NET Framework SDK, which includes another set of class libraries (the .NET Base Class Libraries, ASP.NET, ADO.NET, and Windows Forms) along with command-line compilers and utilities for .NET development.

Visual C++ is available in several editions, all at different prices. The umbrella product, Visual Studio, comes with Visual C++ as well as Visual Basic, Visual C# .NET, and other tools. Visual Studio comes in Professional, Enterprise Developer, and Enterprise Architect versions, each of which contains the three mainstream languages (C++, VB, and C#). Visual C++ .NET Standard Edition comes with only Visual C++no VB or C# compilers. In addition, there is an Academic edition and evaluation versions are occasionally available.

This book assumes you're working with the Professional Edition. If a demonstrated feature is from the Enterprise or Enterprise Architect edition, that detail is mentioned.


For years , if someone told you "I'm a Visual C++ programmer," it meant that person knew C++, had learned the MFC class library (and perhaps also the ATL template library), was familiar with the concepts underlying Windows programming and the Windows API, and knew how to use Visual C++ to write MFC and ATL applications for Windows, or for class libraries and components .

Those skills don't always translate well to the .NET way of building applications and libraries. A Visual C++ .NET programmer building managed applications has more in common with a Visual Basic .NET programmer or a C# programmer than a Visual C++ 6 programmer. To use Visual C++ .NET to build applications for the .NET Framework, you need to understand the concepts behind .NET, and learn an integrated development environment that's quite different from Visual C++ 6. That's what this book is here to help you learn.

The first release of Visual C++ that could produce managed code and target the .NET Common Language Runtime was named Visual C++ .NET, and was part of Visual Studio .NET, released in the spring of 2002. Since then, the new release of those products includes the moniker 2003; for example, Visual C++ .NET 2003. The older product has been renamed Visual C++ .NET 2002, part of Visual Studio .NET 2002. The changes between the 2002 and 2003 versions are relatively minor in most of the .NET languages, but they're quite dramatic in Visual C++. This book covers the 2003 product. The architectural concepts of .NET and the description of the class libraries included in the .NET Framework are applicable if you're using the 2002 product, but the menu choices, wizards, code generators, and the like are quite different in the 2003 release.

The Managed Extensions to C++

It's long been a convention among C++ compiler developers that any identifier that starts with an underscore belongs to the compiler. Don't start your variable or function names with an underscore, and you'll never accidentally overwrite something the compiler was using. A similar convention is to use double underscores at the start of identifiers and keywords that are compiler-specific (implemented by one compiler vendor but not by others). This reminds developers who use these features that the work they are doing would not compile or run properly if it were built with a different compiler.

Although all compilers have a handful of compiler-specific keywords, these extensions haven't really been important to developers in the past. Millions of lines of code have been written that didn't knowingly use compiler-specific code. (The qualifier knowingly applies because compilers vary dramatically in their standards compliance, and code that compiles and works under one compiler might behave quite differently under another.) Developers have chosen C++ development tools based on criteria like the strength of the class library, or the ease of use of the integrated editor, not the collection of extension keywords offered by the compiler itself.

With the introduction of Visual C++ .NET in 2002, that situation changed. Continuing in Visual C++ .NET 2003, developers use a series of extension keywords (known as the Managed Extensions to C++) to generate code that targets the .NET Framework, also called managed code . One of the requirements for the team developing Visual C++ .NET was that existing code must compile and run without errorwhether the code now ran in the framework or not. Therefore, the development team could not change the meaning or behavior of any existing keywords. The "escape hatch" of compiler-specific extensions enabled the team to meet this requirement.

In a printed book, it can be hard to spot the double underscores. Can you see the difference between __gc and _gc ? Could you see it if they didn't appear side by side? There are a lot more leading double underscores in this book's sample code than leading single underscores, so if you're not sure, it's probably a double underscore.

If you learned C++ with a compiler other than Visual C++, you might be concerned that you have another language to learnyou don't. The keywords, syntax, brace brackets, semicolons, and other delights of C++ are exactly the same in Visual C++. What's different are the libraries, wizards, and integrated development environment that combine to make you a more productive programmer no matter what kind of application you're creating.

Applications That Run Directly Under Windows

When you develop an application using Visual C++ .NET 2002 or 2003, it will be either a managed or unmanaged application. In either case, it will be built to run on a Windows machine.

An unmanaged application runs directly under Windows. Even a console application, which runs in a command prompt, runs under Windows. The compiled executable from Visual C++ cannot be executed on a non-Windows machine, although the code itself might be portable. The source code for a console application can be moved to a non-Windows machine and recompiled with a compiler for that machine. That source code would run, assuming it didn't use any Microsoft-specific libraries such as MFC or ATL, did not attempt to load any DLLs or use any COM components, and avoided compiler-specific extensions. Of course, any kind of Windows application other than a console application is utterly nonportable.

A managed application runs in the .NET runtime. As of mid-2003, no versions of the .NET runtime are generally available for platforms other than Windows. A demonstration/academic research version of a subset of the .NET Framework called Rotor runs on at least one flavor of UNIX (FreeBSD) and the Mac. It doesn't include ASP.NET or Web Services, Windows Forms, ADO.NET, or anything Windows-specific such as Registry access. The license agreement prohibits its use for commercial purposes. Another project for implementing the .NET Framework on a non-Windows platform is Mono , which targets Linux and other UNIX flavors. The work is partially complete and a completion date has not been announced.

Because Visual C++ is itself a Windows application, it's a good bet that you'll be using it to create Windows applications. That's the assumption throughout this book.

Microsoft Visual C++. NET 2003 Kick Start
Microsoft Visual C++ .NET 2003 Kick Start
ISBN: 0672326000
EAN: 2147483647
Year: 2002
Pages: 141
Authors: Kate Gregory

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net