Home Page Icon
Home Page
Table of Contents for
IV. Advanced topics
Close
IV. Advanced topics
by Julian Templeman
Microsoft Visual C++/CLI Step by Step
Dedication
Special Upgrade Offer
A Note Regarding Supplemental Files
Introduction
Who should read this book
Assumptions
Who should not read this book
Organization of this book
Finding your best starting point in this book
Conventions and features in this book
System requirements
Code samples
Acknowledgments
Errata and book support
We want to hear from you
Stay in touch
I. Getting Started with C++ .NET
1. Hello C++!
What is C++/CLI?
Your first C++/CLI application
The main function
C++ keywords and identifiers
Creating an executable application—theory
Editing the application source files
Compiling the source files
Running and testing the application
Creating an executable application—practice
Creating a project
Editing the C++ source code
Building the executable
Executing the application
Conclusion
Quick reference
2. Introducing Object-Oriented Programming
What is object-oriented programming?
Features of object-oriented programming languages
Encapsulation
Inheritance
Polymorphism
Classes and objects
Benefits to the development life cycle
A simple example
Quick reference
3. Variables and Operators
What is a variable?
The fundamental data types
Declaring a variable
Variable naming
Declaring multiple variables
Assigning values to variables
Handles and pointers
Arrays
Constants
Typedefs
The .NET Framework String class
Operators and expressions
Assignment operators
Arithmetic operators
Relational and logical operators
Bitwise operators
The ternary operator
Type casting
Operator precedence and associativity
Quick reference
4. Using Functions
Declaring function prototypes
Declaring a simple function prototype
Declaring parameters in a function prototype
Declaring the return type in a function prototype
Declaring default values for function parameters
Defining function bodies
Defining a simple function body
Defining a function body that uses parameters
Defining a function body that returns a value
Calling functions
Calling functions in the sample application
Stepping through the application by using debugger
Understanding local and global scope
Overloading functions
Quick reference
5. Decision and Loop Statements
Making decisions by using the if statement
Performing one-way tests
Performing two-way tests
Performing multiway tests
Performing nested tests
Making decisions by using the switch Statement
Defining simple switch statements
Using fall-through in a switch statement
Performing loops
Using while loops
Using for loops
Using do-while loops
Performing unconditional jumps
Quick reference
6. More About Classes and Objects
Organizing classes into header files and source files
Declaring a class in a header file
Implementing a class in a source file
Creating objects
Initializing objects by using constructors
Defining constructors
Member initialization lists
Defining class-wide members
Defining class-wide data members
Defining class-wide member functions
Class constructors
Using constants in classes
Using class-wide constants
Using instance constants
Defining object relationships
Defining the LoyaltyScheme Class
Implementing the LoyaltyScheme class
Creating and using LoyaltyScheme objects
Testing the application
Quick reference
7. Controlling Object Lifetimes
The .NET approach to object lifetimes
Destruction and finalization
Destructors
Finalizers
A few points about finalizers
Implementing the destructor and finalizer for a class
Using the finalizer
Using the destructor
Objects and stack semantics
Traditional C++ object creation and destruction
Creating objects with stack semantics
Copy constructors
Relating objects with stack semantics
When to use handles?
Quick reference
8. Inheritance
What is inheritance?
Inheritance terminology
Inheritance and code reuse
Designing an inheritance hierarchy
A word on substitutability
Defining a base class
Defining a derived class
Creating derived class objects
Concrete and abstract classes
Overriding member functions
Protected access
Defining sealed classes
Abstract and sealed
Defining and using interfaces
Quick reference
II. Microsoft .NET Programming Basics
9. Value Types
Reference types and value types
The need for value types
Properties of value types
Structures
Creating and using a simple struct
Investigating the structure
The differences between structures and classes
Implementing constructors for a structure
Using one structure within another
Copying structures
Enumerations
Creating and using an enumeration
More about enumerations
Using enumerations in applications
Using memory efficiently
Quick reference
10. Operator Overloading
What is operator overloading?
What types need overloaded operators?
What can you overload?
Rules of overloading
Overloading operators in managed types
Overloading arithmetic operators
Using static operator overloads
What functions can you overload?
Implementing logical operators
Implementing Equals
Implementing increment and decrement
Operators and reference types
Guidelines for providing overloaded operators
Quick reference
12. Arrays and Collections
Native C++ arrays
Passing arrays to functions
Initializing arrays
Multidimensional arrays
Dynamic allocation and arrays
Generic types
Managed arrays
Initialization
Initialization
Arrays and reference types
Using the for each loop with arrays
Multidimensional arrays
The .NET array class
Basic operations on arrays
More advanced array operations
Copying array elements
Searching
Sorting
Using enumerators
Other .NET collection classes
The List<T> class
Other list operations
The SortedList<K,V> class
Other SortedList operations
Generics and templates
The STL/CLR library
The three concepts behind STL
Quick reference
13. Properties
What are properties?
The two kinds of properties
Implementing scalar properties
Errors in properties
Auto-implemented properties
Read-only and write-only properties
Properties, inheritance, and interfaces
Implementing indexed properties
The Bank example
Implementing the Bank class
Adding the Account class
Creating Account class properties
Adding accounts to the Bank class
Implementing the Add and Remove methods
Implementing an indexed property to retrieve accounts
Quick reference
14. Delegates and Events
What are delegates?
What is the purpose of delegates?
Defining delegates
Implementing delegates
Calling static member functions by using delegates
Calling non-static member functions by using delegates
Using multicast delegates
Delegates that return a result
What are events?
Implementing an event source class
Implementing an event receiver
Hooking it all together
Standard events and System::EventHandler
Quick reference
15. The .NET Framework Class Library
What is the .NET Framework?
The Common Language Runtime
The Microsoft Intermediate Language
The Common Type System
The Common Language Specification
The .NET Framework class library
Assemblies
Metadata
The .NET Framework namespaces
Using namespaces in C++ applications
The System namespace
Basic types
Floating-point types
The Collections namespaces
The Collections interfaces
The Diagnostics namespace
The IO namespace
The Windows namespaces
The Net namespaces
The ServiceModel namespaces
The Xml namespaces
The Data namespaces
The Web namespaces
Quick reference
III. Using the .NET Framework
16. Working with Files
The System::IO namespace
Implementing text I/O by using readers and writers
Using TextWriter
The FileStream class
Using TextReader
Working with files and directories
Getting information about files and directories
Binary I/O
The BinaryWriter class
The BinaryReader class
Quick reference
17. Reading and Writing XML
XML and .NET
The .NET XML namespaces
The XML processing classes
Parsing XML by using XmlReader
Creating XmlReaders
Creating XmlReaders
The XmlReaderSettings class
Verifying well-formed XML
Handling attributes
Parsing XML with validation
Writing XML by using XmlTextWriter
Using XmlDocument
What is the W3C DOM?
The XmlDocument class
The XmlNode class
Quick reference
18. Using ADO.NET
What is ADO.NET?
ADO.NET data providers
Provider-independent code
ADO.NET namespaces
ADO.NET assemblies
Creating a connected application
Connecting to a database
Creating and executing a command
Executing a command that modifies data
Executing queries and processing the results
Creating a disconnected application
Disconnected operation using a DataSet
Quick reference
19. Writing a Service by Using Windows Communication Foundation
What is Windows Communication Foundation?
Distributed systems
Services
Characteristics of services
Connectivity
The ABCs of WCF
Endpoints
Address
Base addresses
Metadata Exchange addresses
Binding
Contract
Message exchange patterns
Behaviors
Creating a service
Writing a service client
Adding metadata to the service
Accessing a service by using a proxy
Creating the wrapper DLL
Using the wrapper
Quick reference
20. Introducing Windows Store Apps
A (brief) history of writing Windows user interface applications
The Win32 API
Microsoft Foundation Classes
Windows Forms
Windows Presentation Foundation
Windows 8 and Windows Store
Which UI library to choose?
Introducing Windows Store apps
Main features of Windows Store apps
App behavior
Hardware usage
The UI model
Contracts and charms
The WinRT APIs
Writing a Windows Store app
Creating your first Windows Store app
Examining the project
Introducing XAML
What is XAML?
XAML syntax
XAML controls
Layout controls
Event handling
C++/CX and Windows RT
Windows RT
Metadata
C++/CX syntax
Classes
Generics
Strings
Common namespaces
The Windows namespaces
The Platform namespaces
Quick reference
21. More About Windows Store Apps
Building the basic calculator
Laying out the number buttons
Handling number input
Adding arithmetic operations
Adding the arithmetic buttons
Getting the number
Remembering the operation
Performing calculations
Adding the handler and getting the number
Performing the arithmetic operation
Testing the calculator
Improving the graphics
Creating and using a tile
Handling different number bases
Adding the hexadecimal and base buttons
Changing the base
Converting the string in the display
Using app bars
Defining the button styles
Adding an app bar
Hooking it up
Adding sharing
Contracts and charms
Implementing sharing
The DataPackage class
Handling share requests
Where next?
Quick reference
IV. Advanced topics
22. Working with Unmanaged Code
Managed vs. unmanaged code
Mixed classes
The GCHandle type
Pinning and boxing
Interior pointers
Pinning pointers
Boxing and unboxing
Boxing
Unboxing
Using P/Invoke to call functions in the Win32 API
The DllImportAttribute class
Passing structures
Quick reference
23. Attributes and Reflection
Metadata and attributes
Using ILDASM
Using predefined attributes
The AssemblyInfo.cpp file
Using the predefined attribute classes
Defining your own attributes
Attribute class properties
Design criteria for attribute classes
Writing a custom attribute
Using reflection to obtain attribute data
The Type class
Accessing standard attributes
Accessing custom attribute data
Quick reference
24. Living with COM
COM components and the COM Interop
Using COM components from .NET code
How do RCWs work?
Creating and using RCWs
Handling COM errors
Late binding to COM objects
Using .NET components as COM components
What must .NET types implement to be used as COM objects?
Quick reference
Index
About the Author
Special Upgrade Offer
Copyright
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
21. More About Windows Store Apps
Next
Next Chapter
22. Working with Unmanaged Code
Part IV. Advanced topics
Chapter 22
Chapter 23
Chapter 24
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset