Microsoft Visual C++/CLI Step by Step
Julian Templeman
Published by Microsoft Press
I would like to dedicate this book to my wife, Jane, without whose steadfast love and support none of this would be possible .
JULIAN TEMPLEMAN
Special Upgrade Offer
If you purchased this ebook directly from oreilly.com, you have the following benefits:
DRM-free ebooksuse your ebooks across devices without restrictions or limitations
Multiple formatsuse on your laptop, tablet, or phone
Lifetime access, with free updates
Dropbox syncingyour files, anywhere
If you purchased this ebook from another retailer, you can upgrade your ebook to take advantage of all these benefits for just $4.99. to access your ebook upgrade.
Please note that upgrade offers are not available from sample content.
A Note Regarding Supplemental Files
Supplemental files and examples for this book can be found at http://examples.oreilly.com/9780735675179-files/. Please use a standard desktop web browser to access these files, as they may not be accessible from all ereader devices.
All code files or examples referenced in the book will be available online. For physical books that ship with an accompanying disc, whenever possible, weve posted all CD/DVD content. Note that while we provide as much of the media content as we are able via free download, we are sometimes limited by licensing restrictions. Please direct any questions or concerns to .
Introduction
C++ is a powerful, industrial-strength programming language used in tens of thousands of applications around the world, and this book will show you how to get started using C++ on Windows.
Of all the languages supported by Microsoft, C++ gives you access to the widest range of technologies on the Windows platform, from writing games, through low-level system software, to line-of-business applications. This book is going to introduce you to several of the areas in which C++ is used in Windows development.
For over a decade .NET has become established as the way to write desktop applications for Windows, and it provides a wealth of technologies to support developers. C++/CLI is the variant of C++ that runs in the .NET environment, and you can use it, along with other languages such as C#, to create rich desktop applications.
More recently, Windows 8 has introduced many new features to the Windows operating system, but perhaps the most exciting is the debut of Windows Store applications. These graphical applications are designed to run on touch screen and mobile devices, and provide a completely new way to construct user interfaces on Windows. C++ is one of the main languages supported for Windows Store development, and this book will give you an introduction to these applications and how to develop them in C++/CX, another variant of C++ introduced specifically for this purpose.
Who should read this book
This book exists to help programmers learn how to write applications using C++ on the Windows platform. It will be useful to those who want an introduction to writing .NET applications using C++, as well as to those who want to see how to write Windows Store applications.
If you are specifically interested in Windows Store applications, you may wish to look at Build Windows 8 Apps with Microsoft Visual C++ Step by Step by Luca Regnicoli, Paolo Pialorsi, and Roberto Brunetti, published by Microsoft Press.
Assumptions
This book expects that you have some experience of programming in a high-level language, so that you are familiar with concepts such as functions and arrays. It is quite sufficient to have experience in a procedural language such as Visual Basic, and I do not assume that you have any experience of object-oriented programming in general, or of C++ in particular (although any knowledge of a curly bracket language will be useful).
Who should not read this book
This book is not suitable for complete beginners to programming. For readers who are completely new to programming and want to learn C++, I recommend starting with a book such as Programming: Principles and Practice Using C++ by Bjarne Stroustrup, published by Addison-Wesley.
This book is also not suitable for those who want to learn standard C++ or older-style Win32 development, because it concentrates on two Microsoft variants (C++/CLI and C++/CX) and does not cover topics such as the CLR or MFC in any detail.
Organization of this book
This book is divided into four sections.
, introduces the main parts of the C++ language, getting you used to coding in C++ and building applications in Visual Studio 2012.
, continues by introducing those parts of C++ that are specific to Microsofts C++/CLI language.
, covers the main features in the .NET Framework libraries used for writing .NET applications. This part includes discussion of working with files, XML and databases, and creating graphical applications.
, covers some more advanced material, including details for working with legacy code.
Finding your best starting point in this book
The various sections of this book cover a wide range of technologies associated with C++ on the Windows platform. Depending on your needs and your existing understanding of C++, you may wish to focus on specific areas of the book. Use the following table to determine how best to proceed through the book.
If you are | Follow these steps |
New to C++ | Read carefully before continuing to the rest of the book. |
Familiar with OO programming but not with C++ | Read . |
Familiar with C++ | Review , looking for the differences between standard C++ and C++/CLI. |
Familiar with .NET, but not Windows Store applications. | Read Chapters . |
Most of the books chapters include exercises that let you try out the concepts you have just learned. Solutions to these exercises can be downloaded using the companion code link from this books web page on oreilly.com. See the section for details on how to download the companion code.
Conventions and features in this book
This book presents information using conventions designed to make the information readable and easy to follow.
Each exercise consists of a series of tasks, presented as numbered steps (1, 2, and so on) listing each action you must take to complete the exercise.
Boxed elements with labels such as Note provide additional information or alternative methods for completing a step successfully.
Text that you type (apart from code blocks) appears in bold.
A plus sign (+) between two key names means that you must press those keys at the same time. For example, Press Alt+Tab means that you hold down the Alt key while you press the Tab key.
A vertical bar between two or more menu items (e.g., File | Close) means that you should select the first menu or menu item, then the next, and so on.
System requirements
You will need the following hardware and software to complete the practice exercises in this book:
One of Windows 7, Windows 8, Windows Server 2008 with Service Pack 2, or Windows Server 2008 R2. Note that if you want to build and run the Windows Store applications featured in Chapters , you will need Windows 8.