在好例子网,分享、交流、成长!
您当前所在位置:首页C/C++ 开发实例Android手机应用开发 → Visual C++ 入门经典(英文版).pdf

Visual C++ 入门经典(英文版).pdf

Android手机应用开发

下载此实例
  • 开发语言:C/C++
  • 实例大小:48.31M
  • 下载次数:16
  • 浏览次数:97
  • 发布时间:2022-03-01
  • 实例类别:Android手机应用开发
  • 发 布 人:xiefeng9527
  • 文件格式:.pdf
  • 所需积分:2
 相关标签: 经典 教程

实例介绍

【实例简介】Visual C 入门经典

【实例截图】


【核心代码】

CONTENTS
INTRODUCTION xxxiii
CHAPTER 1: PROGRAMMING WITH VISUAL C 2010 1
The .NET Framework 2
The Common Language Runtime 2
Writing C Applications 3
Learning Windows Programming 5
Learning C 5
The C Standards 5
Attributes 6
Console Applications 6
Windows Programming Concepts 7
What Is the Integrated Development Environment? 9
The Editor 9
The Compiler 10
The Linker 10
The Libraries 10
Using the IDE 10
Toolbar Options 12
Dockable Toolbars 12
Documentation 13
Projects and Solutions 13
Setting Options in Visual C 2010 27
Creating and Executing Windows Applications 28
Creating a Windows Forms Application 31
Summary 32
CHAPTER 2: DATA, VARIABLES, AND CALCULATIONS 35
The Structure of a C Program 36
The main() Function 44
Program Statements 44
Whitespace 46
Statement Blocks 47
Automatically Generated Console Programs 47
xviii
CONTENTS
Defi ning Variables 49
Naming Variables 49
Declaring Variables 50
Initial Values for Variables 51
Fundamental Data Types 52
Integer Variables 52
Character Data Types 53
Integer Type Modifi ers 55
The Boolean Type 56
Floating-Point Types 56
Literals 58
Defi ning Synonyms for Data Types 59
Variables with Specifi c Sets of Values 59
Basic Input/Output Operations 61
Input from the Keyboard 61
Output to the Command Line 62
Formatting the Output 63
Escape Sequences 64
Calculating in C 66
The Assignment Statement 66
Arithmetic Operations 67
Calculating a Remainder 72
Modifying a Variable 73
The Increment and Decrement Operators 74
The Sequence of Calculation 76
Type Conversion and Casting 78
Type Conversion in Assignments 79
Explicit Type Conversion 79
Old-Style Casts 80
The Auto Keyword 81
Discovering Types 81
The Bitwise Operators 82
The Bitwise AND 82
The Bitwise OR 84
The Bitwise Exclusive OR 85
The Bitwise NOT 86
The Bitwise Shift Operators 86
Introducing Lvalues and Rvalues 88
Understanding Storage Duration and Scope 89
Automatic Variables 89
Positioning Variable Declarations 92
xix
CONTENTS
Global Variables 92
Static Variables 96
Namespaces 96
Declaring a Namespace 97
Multiple Namespaces 99
C /CLI Programming 100
C /CLI Specifi c: Fundamental Data Types 101
C /CLI Output to the Command Line 105
C /CLI Specifi c — Formatting the Output 106
C /CLI Input from the Keyboard 109
Using safe_cast 110
C /CLI Enumerations 111
Discovering C /CLI Types 116
Summary 116
CHAPTER 3: DECISIONS AND LOOPS 121
Comparing Values 121
The if Statement 123
Nested if Statements 124
Nested if-else Statements 128
Logical Operators and Expressions 130
The Conditional Operator 133
The switch Statement 135
Unconditional Branching 139
Repeating a Block of Statements 139
What Is a Loop? 139
Variations on the for Loop 142
The while Loop 150
The do-while Loop 152
Nested Loops 154
C /CLI Programming 157
The for each Loop 161
Summary 163
CHAPTER 4: ARRAYS, STRINGS, AND POINTERS 167
Handling Multiple Data Values of the Same Type 168
Arrays 168
Declaring Arrays 169
Initializing Arrays 172
Character Arrays and String Handling 174
Multidimensional Arrays 177
xx
CONTENTS
Indirect Data Access 180
What Is a Pointer? 181
Declaring Pointers 181
Using Pointers 182
Initializing Pointers 183
The sizeof Operator 190
Constant Pointers and Pointers to Constants 192
Pointers and Arrays 194
Dynamic Memory Allocation 201
The Free Store, Alias the Heap 201
The new and delete Operators 202
Allocating Memory Dynamically for Arrays 203
Dynamic Allocation of Multidimensional Arrays 206
Using References 206
What Is a Reference? 207
Declaring and Initializing Lvalue References 207
Defi ning and Initializing Rvalue References 208
Native C Library Functions for Strings 208
Finding the Length of a Null-Terminated String 209
Joining Null-Terminated Strings 210
Copying Null-Terminated Strings 211
Comparing Null-Terminated Strings 212
Searching Null-Terminated Strings 213
C /CLI Programming 215
Tracking Handles 216
CLR Arrays 217
Strings 233
Tracking References 244
Interior Pointers 244
Summary 247
CHAPTER 5: INTRODUCING STRUCTURE INTO YOUR PROGRAMS 251
Understanding Functions 252
Why Do You Need Functions? 253
Structure of a Function 253
Using a Function 256
Passing Arguments to a Function 259
The Pass-by-value Mechanism 260
Pointers as Arguments to a Function 262
Passing Arrays to a Function 263
References as Arguments to a Function 267
xxi
CONTENTS
Use of the const Modifi er 270
Rvalue Reference Parameters 271
Arguments to main() 273
Accepting a Variable Number of Function Arguments 275
Returning Values from a Function 277
Returning a Pointer 277
Returning a Reference 280
Static Variables in a Function 283
Recursive Function Calls 285
Using Recursion 288
C /CLI Programming 289
Functions Accepting a Variable Number of Arguments 289
Arguments to main() 290
Summary 292
CHAPTER 6: MORE ABOUT PROGRAM STRUCTURE 295
Pointers to Functions 295
Declaring Pointers to Functions 296
A Pointer to a Function as an Argument 299
Arrays of Pointers to Functions 301
Initializing Function Parameters 302
Exceptions 303
Throwing Exceptions 305
Catching Exceptions 306
Exception Handling in the MFC 307
Handling Memory Allocation Errors 308
Function Overloading 310
What Is Function Overloading? 310
Reference Types and Overload Selection 313
When to Overload Functions 313
Function Templates 314
Using a Function Template 314
Using the decltype Operator 317
An Example Using Functions 318
Implementing a Calculator 319
Eliminating Blanks from a String 322
Evaluating an Expression 322
Getting the Value of a Term 325
Analyzing a Number 326
Putting the Program Together 330
Extending the Program 331
xxii
CONTENTS
Extracting a Substring 333
Running the Modifi ed Program 336
C /CLI Programming 336
Understanding Generic Functions 337
A Calculator Program for the CLR 343
Summary 349
CHAPTER 7: DEFINING YOUR OWN DATA TYPES 353
The struct in C 354
What Is a struct? 354
Defi ning a struct 354
Initializing a struct 355
Accessing the Members of a struct 355
IntelliSense Assistance with Structures 359
The struct RECT 360
Using Pointers with a struct 361
Data Types, Objects, Classes, and Instances 363
First Class 364
Operations on Classes 364
Terminology 365
Understanding Classes 366
Defi ning a Class 366
Declaring Objects of a Class 367
Accessing the Data Members of a Class 367
Member Functions of a Class 370
Positioning a Member Function Defi nition 372
Inline Functions 372
Class Constructors 374
What Is a Constructor? 374
The Default Constructor 376
Assigning Default Parameter Values in a Class 378
Using an Initialization List in a Constructor 381
Making a Constructor Explicit 381
Private Members of a Class 382
Accessing private Class Members 385
The friend Functions of a Class 386
The Default Copy Constructor 388
The Pointer this 390
const Objects 393
const Member Functions of a Class 393
Member Function Defi nitions Outside the Class 394
xxiii
CONTENTS
Arrays of Objects 395
Static Members of a Class 397
Static Data Members 397
Static Function Members of a Class 401
Pointers and References to Class Objects 401
Pointers to Objects 401
References to Class Objects 404
C /CLI Programming 406
Defi ning Value Class Types 407
Defi ning Reference Class Types 412
Defi ning a Copy Constructor for a Reference Class Type 415
Class Properties 416
initonly Fields 429
Static Constructors 431
Summary 432
CHAPTER 8: MORE ON CLASSES 435
Class Destructors 435
What Is a Destructor? 436
The Default Destructor 436
Destructors and Dynamic Memory Allocation 438
Implementing a Copy Constructor 442
Sharing Memory Between Variables 444
Defi ning Unions 444
Anonymous Unions 446
Unions in Classes and Structures 446
Operator Overloading 446
Implementing an Overloaded Operator 447
Implementing Full Support for a Comparison Operator 450
Overloading the Assignment Operator 454
Overloading the Addition Operator 459
Overloading the Increment and Decrement Operators 463
Overloading the Function Call Operator 465
The Object Copying Problem 466
Avoiding Unnecessary Copy Operations 466
Applying Rvalue Reference Parameters 470
Named Objects are Lvalues 472
Class Templates 477
Defi ning a Class Template 478
Creating Objects from a Class Template 481
Class Templates with Multiple Parameters 483
Templates for Function Objects 486
xxiv
CONTENTS
Using Classes 486
The Idea of a Class Interface 486
Defi ning the Problem 487
Implementing the CBox Class 487
Organizing Your Program Code 508
Naming Program Files 509
Native C Library Classes for Strings 510
Creating String Objects 510
Concatenating Strings 512
Accessing and Modifying Strings 516
Comparing Strings 520
Searching Strings 523
C /CLI Programming 533
Overloading Operators in Value Classes 534
Overloading the Increment and Decrement Operators 540
Overloading Operators in Reference Classes 540
Implementing the Assignment Operator for Reference Types 543
Summary 544
CHAPTER 9: CLASS INHERITANCE AND VIRTUAL FUNCTIONS 549
Object-Oriented Programming Basics 549
Inheritance in Classes 551
What Is a Base Class? 551
Deriving Classes from a Base Class 552
Access Control Under Inheritance 555
Constructor Operation in a Derived Class 558
Declaring Protected Class Members 562
The Access Level of Inherited Class Members 565
The Copy Constructor in a Derived Class 566
Class Members as Friends 569
Friend Classes 571
Limitations on Class Friendship 572
Virtual Functions 572
What Is a Virtual Function? 574
Using Pointers to Class Objects 576
Using References with Virtual Functions 578
Pure Virtual Functions 580
Abstract Classes 581
Indirect Base Classes 584
Virtual Destructors 586
Casting Between Class Types 590
xxv
CONTENTS
Nested Classes 590
C /CLI Programming 594
Boxing and Unboxing 594
Inheritance in C /CLI Classes 595
Interface Classes 602
Defi ning Interface Classes 602
Classes and Assemblies 606
Functions Specifi ed as new 611
Delegates and Events 612
Destructors and Finalizers in Reference Classes 625
Generic Classes 628
Summary 638
CHAPTER 10: THE STANDARD TEMPLATE LIBRARY 645
What Is the Standard Template Library? 645
Containers 646
Container Adapters 647
Iterators 648
Algorithms 649
Function Objects in the STL 650
Function Adapters 650
The Range of STL Containers 651
Sequence Containers 651
Creating Vector Containers 652
The Capacity and Size of a Vector Container 655
Accessing the Elements in a Vector 660
Inserting and Deleting Elements in a Vector 661
Storing Class Objects in a Vector 663
Sorting Vector Elements 668
Storing Pointers in a Vector 669
Double-Ended Queue Containers 671
Using List Containers 675
Using Other Sequence Containers 685
Associative Containers 701
Using Map Containers 702
Using a Multimap Container 714
More on Iterators 715
Using Input Stream Iterators 715
Using Inserter Iterators 719
Using Output Stream Iterators 720
More on Function Objects 723
xxvi
CONTENTS
More on Algorithms 724
fi ll() 725
replace() 725
fi nd() 725
transform() 726
Lambda Expressions 727
The Capture Clause 728
Capturing Specifi c Variables 730
Templates and Lambda Expressions 730
Wrapping a Lambda Expression 734
The STL for C /CLI Programs 736
STL/CLR Containers 737
Using Sequence Containers 737
Using Associative Containers 745
Lambda Expressions in C /CLI 752
Summary 752
CHAPTER 11: DEBUGGING TECHNIQUES 755
Understanding Debugging 756
Program Bugs 757
Common Bugs 758
Basic Debugging Operations 759
Setting Breakpoints 761
Setting Tracepoints 763
Starting Debugging 763
Changing the Value of a Variable 767
Adding Debugging Code 767
Using Assertions 768
Adding Your Own Debugging Code 769
Debugging a Program 775
The Call Stack 775
Step Over to the Error 777
Testing the Extended Class 780
Finding the Next Bug 783
Debugging Dynamic Memory 783
Functions for Checking the Free Store 784
Controlling Free Store Debug Operations 785
Free Store Debugging Output 786
Debugging C /CLI Programs 793
Using the Debug and Trace Classes 793
Getting Trace Output in Windows Forms Applications 803
Summary 804
xxvii
CONTENTS
CHAPTER 12: WINDOWS PROGRAMMING CONCEPTS 807
Windows Programming Basics 808
Elements of a Window 808
Windows Programs and the Operating System 810
Event-Driven Programs 811
Windows Messages 811
The Windows API 811
Windows Data Types 812
Notation in Windows Programs 813
The Structure of a Windows Program 814
The WinMain() Function 815
Message Processing Functions 827
A Simple Windows Program 833
Windows Program Organization 834
The Microsoft Foundation Classes 835
MFC Notation 836
How an MFC Program Is Structured 836
Using Windows Forms 840
Summary 841
CHAPTER 13: PROGRAMMING FOR MULTIPLE CORES 843
Parallel Processing Basics 843
Introducing the Parallel Patterns Library 844
Algorithms for Parallel Processing 844
Using the parallel_for Algorithm 845
Using the parallel_for_each Algorithm 846
Using the parallel_invoke Algorithm 849
A Real Parallel Problem 850
Critical Sections 864
Using critical_section Objects 865
Locking and Unlocking a Section of Code 865
The combinable Class Template 867
Tasks and Task Groups 869
Summary 873
CHAPTER 14: WINDOWS PROGRAMMING WITH THE MICROSOFT
FOUNDATION CLASSES 875
The Document/View Concept in MFC 876
What Is a Document? 876
Document Interfaces 876
What Is a View? 877
xxviii
CONTENTS
Linking a Document and Its Views 878
Your Application and MFC 879
Creating MFC Applications 880
Creating an SDI Application 882
MFC Application Wizard Output 886
Creating an MDI Application 897
Summary 899
CHAPTER 15: WORKING WITH MENUS AND TOOLBARS 903
Communicating with Windows 903
Understanding Message Maps 904
Message Categories 907
Handling Messages in Your Program 908
Extending the Sketcher Program 909
Elements of a Menu 910
Creating and Editing Menu Resources 910
Adding Handlers for Menu Messages 913
Choosing a Class to Handle Menu Messages 914
Creating Menu Message Functions 915
Coding Menu Message Functions 916
Adding Message Handlers to Update the User Interface 920
Adding Toolbar Buttons 924
Editing Toolbar Button Properties 925
Exercising the Toolbar Buttons 926
Adding Tooltips 927
Menus and Toolbars in a C /CLI Program 928
Understanding Windows Forms 928
Understanding Windows Forms Applications 929
Adding a Menu to CLR Sketcher 932
Adding Event Handlers for Menu Items 935
Implementing Event Handlers 936
Setting Menu Item Checks 937
Adding a Toolbar 938
Summary 942
CHAPTER 16: DRAWING IN A WINDOW 945
Basics of Drawing in a Window 945
The Window Client Area 946
The Windows Graphical Device Interface 946
xxix
CONTENTS
The Drawing Mechanism in Visual C 948
The View Class in Your Application 949
The CDC Class 950
Drawing Graphics in Practice 959
Programming for the Mouse 961
Messages from the Mouse 962
Mouse Message Handlers 963
Drawing Using the Mouse 965
Exercising Sketcher 990
Running the Example 991
Capturing Mouse Messages 992
Drawing with the CLR 993
Drawing on a Form 993
Adding Mouse Event Handlers 994
Defi ning C /CLI Element Classes 996
Implementing the MouseMove Event Handler 1004
Implementing the MouseUp Event Handler 1005
Implementing the Paint Event Handler for the Form 1006
Summary 1007
CHAPTER 17: CREATING THE DOCUMENT AND IMPROVING
THE VIEW 1009
Creating the Sketch Document 1009
Using a list<T> Container for the Sketch 1010
Improving the View 1014
Updating Multiple Views 1014
Scrolling Views 1016
Using MM_LOENGLISH Mapping Mode 1021
Deleting and Moving Shapes 1022
Implementing a Context Menu 1022
Associating a Menu with a Class 1023
Exercising the Pop-Ups 1026
Highlighting Elements 1026
Servicing the Menu Messages 1030
Dealing with Masked Elements 1038
Extending CLR Sketcher 1039
Coordinate System Transformations 1039
Defi ning a Sketch Class 1042
Drawing the Sketch in the Paint Event Handler 1044
Implementing Element Highlighting 1044
Creating Context Menus 1050
Summary 1056
xxx
CONTENTS
CHAPTER 18: WORKING WITH DIALOGS AND CONTROLS 1059
Understanding Dialogs 1059
Understanding Controls 1060
Creating a Dialog Resource 1061
Adding Controls to a Dialog Box 1062
Testing the Dialog 1063
Programming for a Dialog 1063
Adding a Dialog Class 1063
Modal and Modeless Dialogs 1064
Displaying a Dialog 1065
Supporting the Dialog Controls 1067
Initializing the Controls 1068
Handling Radio Button Messages 1069
Completing Dialog Operations 1069
Adding Pen Widths to the Document 1070
Adding Pen Widths to the Elements 1070
Creating Elements in the View 1071
Exercising the Dialog 1072
Using a Spin Button Control 1072
Adding the Scale Menu Item and Toolbar Button 1073
Creating the Spin Button 1073
Generating the Scale Dialog Class 1074
Displaying the Spin Button 1077
Using the Scale Factor 1078
Scalable Mapping Modes 1078
Setting the Document Size 1080
Setting the Mapping Mode 1080
Implementing Scrolling with Scaling 1082
Using the CTaskDialog Class 1084
Displaying a Task Dialog 1084
Creating CTaskDialog Objects 1086
Working with Status Bars 1089
Adding a Status Bar to a Frame 1089
Using a List Box 1093
Removing the Scale Dialog 1093
Creating a List Box Control 1094
Using an Edit Box Control 1096
Creating an Edit Box Resource 1096
Creating the Dialog Class 1097
Adding the Text Menu Item 1099
Defi ning a Text Element 1100
Implementing the CText Class 1100
xxxi
CONTENTS
Dialogs and Controls in CLR Sketcher 1105
Adding a Dialog 1106
Creating Text Elements 1112
Summary 1120
CHAPTER 19: STORING AND PRINTING DOCUMENTS 1123
Understanding Serialization 1123
Serializing a Document 1124
Serialization in the Document Class Defi nition 1124
Serialization in the Document Class Implementation 1125
Functionality of CObject-Based Classes 1128
How Serialization Works 1129
How to Implement Serialization for a Class 1131
Applying Serialization 1131
Recording Document Changes 1131
Serializing the Document 1133
Serializing the Element Classes 1135
Exercising Serialization 1139
Printing a Document 1140
The Printing Process 1141
Implementing Multipage Printing 1144
Getting the Overall Document Size 1145
Storing Print Data 1146
Preparing to Print 1147
Cleaning Up after Printing 1148
Preparing the Device Context 1149
Printing the Document 1150
Getting a Printout of the Document 1154
Serialization and Printing in CLR Sketcher 1155
Understanding Binary Serialization 1155
Serializing a Sketch 1160
Printing a Sketch 1171
Summary 1172
CHAPTER 20: WRITING YOUR OWN DLLs 1175
Understanding DLLs 1175
How DLLs Work 1177
Contents of a DLL 1180
DLL Varieties 1180
xxxii
CONTENTS
Deciding What to Put in a DLL 1181
Writing DLLs 1182
Writing and Using an Extension DLL 1182
Summary 1190
INDEX 1193

标签: 经典 教程

实例下载地址

Visual C++ 入门经典(英文版).pdf

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警