Introduction xxxiii
Chapter 1: Programming with Visual C++ 1
Learning with Visual C++ 1
Writing C++ Applications 2
Learning Desktop Applications Programming 3
The Integrated Development Environment 6
Using the IDE 8
Summary 23
Chapter 2: Data, Variables, and Calculations 25
The Structure of a C++ Program 26
Defining Variables 38
Fundamental Data Types 40
Basic Input/Output Operations 47
Calculating in C++ 52
Type Conversion and Casting 63
The auto Keyword 65
Discovering Types 66
The Bitwise Operators 67
Introducing Lvalues and Rvalues 72
Understanding Storage Duration and Scope 72
Variables with Specific Sets of Values 79
Namespaces 83
Summary 86
Chapter 3: Decisions and Loops 91
Repeating a Block of Statements 109
Summary 127
Chapter 4: Arrays, Strings, and Pointers 129
Handling Multiple Data Values of the Same Type 129
Working with C-Style Strings 140
Indirect Data Access 146
Dynamic Memory Allocation 163
Using References 168
Library Functions for Strings 171
Summary 176
Chapter 5: Introducing Structure into Your Programs 179
Understanding Functions 179
Passing Arguments to a Function 188
Returning Values from a Function 206
Returning a Pointer 206
Recursive Function Calls 214
Summary 217
Chapter 6: More about Program Structure 221
Pointers to Functions 221
Initializing Function Parameters 228
Exceptions 229
Handling Memory Allocation Errors 235
Function Overloading 237
Function Templates 241
Using the decltype Operator 244
An Example Using Functions 246
Summary 264
Chapter 7: Defining Your Own Data Types 267
The struct in C++ 267
Types, Objects, Classes, and Instances 276
Understanding Classes 279
Class Constructors 287
Private Members of a Class 297
The Pointer this 304
Const Objects 306
Arrays of Objects 309
Static Members of a Class 310
Pointers and References to Objects 314
Summary 318
Chapter 8: More on Classes 323
Class Destructors 324
Implementing a Copy Constructor 329
Operator Overloading 331
The Object Copying Problem 351
Default Class Members 361
Class Templates 362
Perfect Forwarding 373
Default Arguments for Template Parameters 376
Aliases for Class Templates 381
Template Specialization 382
Using Classes 385
Organizing Your Program Code 403
Library Classes for Strings 405
Summary 427
Chapter 9: Class Inheritance and Virtual Functions 431
Object-Oriented Programming Basics 432
Inheritance in Classes 433
Access Control Under Inheritance 437
The Copy Constructor in a Derived Class 447
Preventing Class Derivation 450
Class Members as Friends 451
Virtual Functions 453
Casting Between Class Types 470
Summary 475
Chapter 10: The Standard Template Library 479
What Is the Standard Template Library? 479
Smart Pointers 485
Algorithms 488
Function Objects in the STL 489
Function Adapters 490
The Range of STL Containers 490
Sequence Containers 490
Associative Containers 543
More on Iterators 556
More on Function Objects 562
More on Algorithms 564
Type Traits and Static Assertions 566
Lambda Expressions 567
Summary 577
Chapter 11: Windows Programming Concepts 579
Windows Programming Basics 580
The Structure of a Windows Program 586
The Microsoft Foundation Classes 605
Summary 610
Chapter 12: Windows Programming with the Microsoft Foundation Classes (MF C) 613
The MFC Document/View Concept 614
Creating MFC Applications 618
Summary 635
Chapter 13: Working with Menus and Toolbars 637
Communicating with Windows 637
Extending the Sketcher Program 642
Elements of a Menu 643
Adding Menu Message Handlers 646
Adding Toolbar Buttons 656
Summary 660
Chapter 14: Drawing in a Window 663
Basics of Drawing in a Window 663
The MFC Drawing Mechanism 667
Drawing Graphics in Practice 678
Programming for the Mouse 680
Drawing a Sketch 709
Summary 713
Chapter 15: Improving the View 717
Sketcher Limitations 717
Improving the View 718
Deleting and Moving Elements 726
Implementing a Context Menu 726
Identifying an Element Under the Cursor 730
Dealing with Masked Elements 743
Summary 745
Chapter 16: Working with Dialogs and Controls 747
Understanding Dialogs 748
Understanding Controls 748
Creating a Dialog Resource 749
Programming for a Dialog 751
Supporting the Dialog Controls 755
Completing Dialog Operations 758
Using a Spin Button Control 763
Using the Scale Factor 769
Working with Status Bars 775
The CString Class 779
Using an Edit Box Control 780
Summary 790
Chapter 17: Storing and Printing Documents 793
Understanding Serialization 793
Applying Serialization 801
Exercising Serialization 809
Printing a Document 811
Implementing Multipage Printing 815
Summary 825
Chapter 18: Programming for Windows 8 827
Windows Store Applications 828
Developing Windows Store Apps 829
Windows Runtime Concepts 829
C++ Component Extensions (C++/CX) 831
The Extensible Application Markup Language (XAML) 836
Creating a Windows Store App 844
Scaling UI Elements 873
Transitions 875
Summary 879
Index 881