Visual C++ Templates

Visual C++ Templates

by William H. Murray, Chris Pappas

Paperback

$49.99

Temporarily Out of Stock Online

Eligible for FREE SHIPPING

Overview

Visual C++ Templates by William H. Murray, Chris Pappas

Join Murray and Pappas in this book as they show you how to combine two new important areas of C++ programming; the Standard Template Library and the MFC library.

Both the STL and the MFC are presented as stand alone concepts. Each topic is thoroughly discussed with numerous programming examples. In these sections, you'll learn important terms, definitions, and how to build simple applications with both the STL and MFC.

The real power of this book is evidenced in third section of the book. Murray and Pappas skillfully integrate the earlier sections and teach you how to build MFC Windows applications using the STL. Here, you'll see practical examples of how the power of the STL can be brought into the MFC Windows programming environment. You'll find the examples to be powerful, concise and on the cutting edge of C++ programming today!

Product Details

ISBN-13: 9780130224873
Publisher: Prentice Hall Professional Technical Reference
Publication date: 12/14/1999
Series: Microsoft Technology Series
Pages: 544
Product dimensions: 6.99(w) x 9.20(h) x 1.42(d)

Read an Excerpt

PREFACE:

Programming with the STL and Windows MFC

This is an exciting time to be a programmer-exciting, but sometimes a little scary. The knowledge base for C and C++ programmers has grown tremendously in the past few years. The first hurtle included procedure-oriented Windows programming, but has now grown to include object-oriented MFC Windows programming, OLE, STL and more!

This book assumes a knowledge of object-oriented C++ programming at the beginner/intermediate level. You'll quickly apply your programming knowledge to these new programming concepts.

In this book, Murray and Pappas will guide you through a solid integrated understanding of the latest STL (Standard Template Library) concepts couple with MFC's (Microsoft Foundation Class library) programming concepts that apply to both Windows 98 and Windows 2000.

The first six chapters deal exclusively with the STL. You'll learn terms, definitions and reasons for using the STL. Many command line examples will teach new programming concepts in simple applications.

In the next six chapters, you'll learn how to develop object-oriented MFC Windows applications. It's all here-wizards, icons, cursors, menus, dialog boxes and more. When you complete this group of chapters, you'll have a solid understanding of object-oriented programming under Windows.

In the final four chapters, STL concepts from the first six chapters are integrated with MFC Windows applications, from the second six chapters, to build robust MFC Windows applications using the STL. When you complete these four chapters, you understand how well both the STL and MFC integrate together to produce powerful newapplications.

Table of Contents

Preface xxiii
Acknowledgments xxiv
What Is the Standard Template Library?
1(12)
The Complexity of Multiplatform Target Environments
1(1)
Unintentional Misuse or Ignorance of C/C++ Features
2(1)
Data Structures---The Course to Separate Hackers from Pros!
3(1)
So, Just What Is the Standard Template Library?
3(1)
The Origins of STL
4(1)
What Do I Need to Know to Take Advantage of STL?
4(1)
A High-Level View of STL
5(1)
Kudos to the ANSI/ISO C++ Committee
5(1)
STL's Tri-Component Nature
6(4)
Containers
6(2)
Container Adapters
8(1)
Algorithms
8(1)
Iterators
9(1)
Additional Elements
10(1)
STL Review
10(1)
In the Following Chapters
11(2)
Understanding Template Syntax
13(50)
Chapter Overview
14(1)
Dynamic Memory Allocation and Pointers
14(5)
Static vs. Dynamic
14(1)
Typed Pointers
15(1)
Void Pointers
16(3)
What's the i in iValue?
19(1)
Function Overloading
20(1)
Pointers to Functions
21(3)
Structures as Objects
24(9)
A Structure as a Primitive Class
24(5)
The Syntax and Rules for C++ Classes
29(1)
A Simple C++ Class
30(3)
C++ Class Objects
33(24)
Additional Class Features
33(1)
Nesting Classes
34(3)
Constructors and Destructors
37(4)
Overloading Class Member Functions
41(4)
Using Friend Functions to Access Private Class Variables
45(3)
Using the this Pointer
48(1)
Using Operator Overloading
48(4)
Derived Classes
52(5)
Templates in C!
57(1)
Structures as Simple Templates
57(1)
C++ Template Keyword
58(2)
Template Syntax
58(1)
Function Templates
58(1)
Class Templates
59(1)
The Need for Standardization
60(1)
Summary
61(2)
Standard C++ Library and STL Fundamentals
63(24)
Latest C++ ANSI/ISO Language Updates
64(3)
Using namespace
64(1)
namespace Syntax
65(1)
The using namespace Statement
65(1)
The Selective using Statement
66(1)
Renaming namespaces
66(1)
static File Scope vs. Unnamed namespaces
66(1)
New Casting Operations
67(2)
Dynamic Casting
67(1)
Static Casting
68(1)
Newer C-Type Cast
68(1)
Constant Cast
69(1)
Run-Time Type Information
69(1)
Introduction to the Standard C++ Library
70(2)
The Standard C++ Libraries
71(1)
Your First Standard C++ Library Application
72(1)
Implementing Your Own Template
73(3)
Your First class Template
73(1)
Function Templates Requirements
74(1)
Using a class Template
74(1)
Class Template Parameters
75(1)
Default Template Parameters
75(1)
The Standard Template Library
76(1)
STL Components
76(1)
Rules for Using STL
77(1)
Function Objects
78(4)
STL Function Objects
78(1)
STL Function Adapters
79(2)
Pointer-to-Function Adapters
81(1)
Standard Template Library Algorithms
81(1)
Standard C++ Library Language Support
82(2)
cstddef
83(1)
Implementation Properties: limits, climits, cfloat
83(1)
Exception Handling
84(1)
Additional Support
84(1)
Summary
85(2)
STL Support Templates
87(20)
From iostream.h to <iostream>
88(1)
From iosream.h to <iostream>
88(1)
Exception Handling Under the New ANSI C/C++/ISO Standard
89(1)
The <utility> and <functional> Templates
90(1)
<utility> Template Syntax
90(5)
struct pair
91(1)
make_pair
92(1)
<utility> Template Overloaded Operators
92(1)
The mak_par.cpp Application
92(1)
The util_oprs.cpp Application
93(2)
<functional> Template Syntax
95(9)
unary_function
97(1)
binary_function
97(1)
plus
98(1)
minus
98(1)
multiplies
98(1)
divides
98(1)
modulus
98(1)
negate
99(1)
equal_to
99(1)
not_equal_to
99(1)
greater
99(1)
less
99(1)
greater_equal
100(1)
less_equal
100(1)
logical_and
100(1)
logical_or
100(1)
logical_not
100(1)
unary_negate
101(1)
binary_negate
101(1)
binder1st
101(1)
binder2nd
102(1)
pointer_to_unary_function
102(1)
pointer_to_binary_function
102(1)
mem_fun_t
103(1)
mem_fun1_t
103(1)
mem_fun_ref_t
103(1)
mem_fun1_ref_t
103(1)
<functional> Template Functions
104(2)
The functnl.cpp Application
104(2)
Summary
106(1)
The STL <algorithm> Template
107(26)
<algorithm> Template Syntax
108(5)
<algorithm> Template Methods
113(11)
Sample Code
124(8)
The find.cpp Application
125(1)
The rndshfl.cpp Application
126(1)
The removif.cpp Application
127(2)
The setunon.cpp Application
129(3)
Summary
132(1)
The STL <iterator> Template
133(20)
Iterator Hierarchy
134(1)
Input and Output Iterators
134(1)
Forward Iterators
134(1)
Bidirectional Iterators
134(1)
Random Iterators
135(1)
Legal Iterator Range
135(1)
Important naming Conventions
135(2)
<iterator> Template Syntax
137(9)
<iterator> Class Definitions
140(6)
<iterator> Template Overloaded Operators
146(1)
<iterator> Template Iterators
147(1)
The iteratr1.cpp Application
147(2)
The iteratr2.cpp Application
149(2)
Summary
151(2)
The <vector> Template
153(18)
Templatized Vectors
154(1)
Instantiating Vectors
154(1)
Understanding Vector Template Functions
155(1)
Accessing <vector> Elements
155(1)
Insertion and Removal of <vector> Elements
156(1)
Two Different Vector Size Descriptors
156(1)
Other <vector> Operations
157(2)
<vector> Template Syntax
159(2)
<vector> Template typedefs
161(1)
<vector> Overloaded Operators
162(1)
<vector> Template Methods
162(3)
Sample Code
165(5)
The vector1.cpp Application
165(3)
The vector2.cpp Application
168(2)
Summary
170(1)
The STL <stack> Template
171(10)
Adaptors'
172(1)
<stack> Template Syntax
172(2)
<stack> Template Overloaded Operators
174(1)
<stack> Template Methods
174(1)
Sample Code
175(4)
The stack.cpp Application
175(4)
Summary
179(2)
The STL and <dequeue> Templates
181(14)
The <queue> Template Syntax
181(1)
<queue> Template Methods
182(1)
The <deque> Template
183(1)
The <deque> Template Syntax
184(1)
<deque> Overloaded Operators
185(1)
<deque> Template Methods
186(3)
Sample Code
189(4)
The queue.cpp Application
189(2)
The deque.cpp Application
191(2)
Summary
193(2)
The STL <list> Template
195(16)
<list> Template Syntax
195(4)
allocator_type
198(1)
size_type
198(1)
difference_type
198(1)
reference
198(1)
const_reference
198(1)
value_type
199(1)
iterator
199(1)
const_iterator
199(1)
reverse_iterator
199(1)
const_reverse_iterator
199(1)
<list> Template Methods
199(4)
Sample Code
203(7)
The list1.cpp Application
203(2)
The list2.cpp Application
205(2)
The list3.cpp Application
207(3)
Summary
210(1)
The STL <map> Template
211(16)
Containers Revisited
211(1)
<map> Template Syntax
212(2)
<map> Template Methods
214(3)
Sample Code
217(9)
The map.cpp Application
218(8)
Summary
226(1)
The STL <numeric> Template
227(24)
Template Syntax
227(1)
Template Methods
228(2)
Sample Code
230(20)
The accum.cpp Application
230(5)
The product.cpp Application
235(3)
The partsum.cpp Application
238(3)
The adjacent.cpp Application
241(2)
Windows Application Using <numeric>
243(7)
Summary
250(1)
The <set> and <multiset> Templates
251(14)
<set> and <multiset> Template Syntax
251(4)
<set> and <multiset> Template Functions
255(1)
<set> Template Methods
256(3)
Sample Code
259(5)
The set1.cpp Application
259(1)
The set2.cpp Application
260(2)
The set3.cpp Application
262(2)
Summary
264(1)
The <memory> Template
265(8)
<memory> Template Syntax
265(1)
<memory> Template Operators
266(1)
<memory> Template Methods
267(2)
Sample Code
269(3)
The new1.cpp Application
269(2)
The size2.cpp Application
271(1)
Summary
272(1)
The <bitset> Template
273(12)
<bitset> Template Syntax
273(2)
<bitset> Template Overloaded Operators
275(1)
<bitset> Template Methods
276(1)
Sample Code
277(6)
The bitset1.cpp Application
277(3)
The bitset2.cpp Application
280(1)
The bitset3.cpp Application
281(1)
The bitset4.cpp Application
282(1)
Summary
283(2)
The <cassert>, <cerrno>, <exception>, and <stdexcept> Standard C++ Headers
285(14)
The <cassert> Header Syntax
285(1)
The <cerrno> Header Syntax
286(3)
Echild
288(1)
Eagain
288(1)
E2Big
288(1)
Eacces
288(1)
Ebadf
288(1)
Edeadlock
288(1)
Edom
288(1)
Eexist
288(1)
Einval
288(1)
Emfile
288(1)
Enoent
289(1)
Enoexec
289(1)
Enomem
289(1)
Enospc
289(1)
Erange
289(1)
Exdev
289(1)
The <exception> Header Syntax
289(3)
exception
290(1)
bad_exception
290(1)
terminate_handler
290(1)
unexpected_handler
291(1)
set_terminate
291(1)
set_unexpected
291(1)
terminateO
291(1)
unexpectedO
291(1)
uncaught_exception
292(1)
The <stdexcept> Header Syntax
292(3)
logic_error class
292(1)
domain_error class
293(1)
invalid_argument class
293(1)
length_error class
293(1)
out_of_range class
293(1)
runtime_error class
294(1)
range_error class
294(1)
overflow_error class
294(1)
underflow_error class
294(1)
Sample Code
295(2)
A <cassert> Application
295(1)
The termin2.cpp Application
296(1)
Summary
297(2)
The <cctype><and <cstring><Standard C++ Headers and <string> Template Class
299(30)
The <cctype> Standard C++ Header Syntax
299(3)
The <cstring> standard C++ Header Syntax
302(6)
<string> Template Syntax
308(11)
<string> Template Functions
310(2)
The basic_string class
312(7)
Sample Code
319(9)
A <cctype> Application
319(2)
A <cstring> Application
321(1)
The First <string> Application
322(2)
The Second <string> Application
324(1)
The Third <string> Application
325(2)
The Fourth <string> Application
327(1)
Summary
328(1)
The <cfloat> and <cmath> Standard C++ Headers and <complex> Template Class
329(40)
The <cfloat> Standard C++ Header Syntax
329(6)
The <cmath> standard C++ Header Syntax
335(10)
Complex Numbers
345(8)
<complex> Template Syntax
347(6)
Sample Code
353(14)
A <cfloat> Application
353(2)
A <cmath> Application
355(2)
The First <complex> Application
357(2)
The Second <complex> Application
359(2)
The Third <complex> Application
361(6)
Summary
367(2)
The <climits>, <limits>, and <csignal> Standard C++ Headers
369(18)
The <climits> Header Syntax
369(5)
Character Ranges
370(1)
Integer Ranges (8 bits)
371(1)
Integer Ranges (16 bits)
371(1)
Integer Ranges (32 bits)
371(1)
Integer Ranges (64 bits)
372(1)
Integer Ranges (128 bits)
372(1)
POSIX Ranges
372(2)
The <limits> Header Syntax
374(5)
has_denorm
375(1)
has_denorm_loss
375(1)
has_infinity
376(1)
has_quiet_Nan
376(1)
has_signaling_NaN
376(1)
is_bounded
376(1)
is_exact
376(1)
is_iec559
376(1)
is_integer
376(1)
is_modulo
376(1)
is_signed
377(1)
is_specialized
377(1)
tinyness_before
377(1)
traps
377(1)
round_style
377(1)
digits
377(1)
digits10
377(1)
max_exponent
377(1)
max_exponent10
378(1)
min_exponent
378(1)
min_exponent10
378(1)
radix
378(1)
denorm_min
378(1)
epsilon
378(1)
infinity
378(1)
max
378(1)
min
379(1)
quiet_NaN
379(1)
round_error
379(1)
signaling_NaN
379(1)
The <csignal> Header Syntax
379(3)
signalO
380(1)
raiseO
381(1)
Sample Code
382(3)
A Range Application
382(1)
The Radix Application
383(1)
The Exponent Application
384(1)
Summary
385(2)
The <cstdarg>, <cstddef>, and <cstdlib> Standard C++ Headers
387(12)
The <cstdarg> Header Syntax
387(2)
The <cstddef> Header Syntax
389(2)
The <cstdlib> Header Syntax
391(4)
<stdlib.h> typedefs
391(1)
<stdlib.h> #defines
392(1)
<stdlib.h> Function Prototypes
393(2)
Sample Code
395(3)
A <cstdarg> Application
395(2)
The <cstdlib> Application
397(1)
Summary
398(1)
The <cstdio> Standard C++ Header
399(14)
The <cstdio> Header Syntax
399(11)
Function Prototypes and Macro Definitions
400(10)
Sample Code
410(2)
An Error-Testing Application
410(1)
A File Read/Write Application
411(1)
Summary
412(1)
The <ctime> Standard C++ Header
413(10)
The <ctime> Header Syntax
413(4)
The <time.h> Function Prototypes
415(2)
Sample Code
417(5)
Using the localtimeO and asctimeO Functions
418(1)
Using the asctimeO and gmtimeO Functions
418(1)
Using the StrftimeO Function
419(1)
Using the ctimeO Function
420(1)
Building a Time Delay Routine
420(2)
Summary
422(1)
The <cwchar> and <cwctype> Standard C++ Header
423(16)
The <cwchar> Header Syntax
423(12)
Interesting <wchar.h> Structures and Constants
424(2)
<wchar> Function Prototypes
426(7)
<wchar> POSIX Function Prototypes and More
433(2)
The <cwctype> Header Syntax
435(1)
Sample Code
435(2)
Summary
437(2)
The <fstream>, <iostream>, <istream>, <ostream>, < sstream>, <streambuf>, and <strstream> Standard C++ Headers
439(24)
The <fstream> Header Syntax
440(2)
basic_filebuf
440(1)
basic_ifstream
441(1)
basic_ofstream
441(1)
basic_fstream
442(1)
The <iostream> Header Syntax
442(1)
The <iostream> Header Syntax
443(3)
basic_istream
444(2)
basic_iostream
446(1)
The <ostream> Header Syntax
446(3)
basic_ostream
447(2)
The <sstream> Header Syntax
449(3)
basic_stringbuf
449(1)
basic_istringstream
450(1)
basic_ostringstream
451(1)
basic_stringstream
451(1)
The <streambuf> Header Syntax
452(2)
basic_streambuf
452(2)
The <strstream> Header Syntax
454(1)
Sample Code
455(7)
The Insertion Operator
455(1)
The Flush Manipulator
455(1)
Using <strstream>
456(6)
Summary
462(1)
The <ios> and <iosfwd> Standard C++ Headers
463(10)
The <ios> Header Syntax
463(5)
ios_base
464(2)
basic_ios
466(1)
fpos
467(1)
Manipulators
467(1)
The <iosfwd> Header Syntax
468(4)
char_traits
470(1)
basic_ios
470(1)
istreambuf_iterator
471(1)
ostreambuf_iterator
471(1)
basic_streambuf, basic_istream, basic_ostream, basic_iostream, basic_stringbuf, basic_istringstream, basic_ostringstream, basic_stringstream, basic_filebuf, basic_ifstream, basic_ofstream, and basic_fstream
472(1)
Sample Code
472(1)
Summary
472(1)
The <valarray> Standard C++ Header
473(18)
The <valarray> Header Syntax
473(10)
valarray
478(2)
slice_array
480(1)
gslice_array
480(1)
mask_array
481(1)
indirect_array
482(1)
Sample Code
483(6)
The maskarray.cpp Application
483(2)
The addvalarray.cpp Application
485(2)
The indirectarray.cpp Application
487(2)
Summary
489(2)
The <ciso646>, <clocale>, <csetjump>, and <locale> Standard C++ Headers
491(12)
The <ciso646> Header Syntax
491(1)
The <clocale> Header Syntax
491(3)
The <csetjump> Header Syntax
494(1)
The <locale> Header Syntax
495(5)
Sample Code
500(2)
Summary
502(1)
Index 503

Preface

PREFACE:

Programming with the STL and Windows MFC

This is an exciting time to be a programmer-exciting, but sometimes a little scary. The knowledge base for C and C++ programmers has grown tremendously in the past few years. The first hurtle included procedure-oriented Windows programming, but has now grown to include object-oriented MFC Windows programming, OLE, STL and more!

This book assumes a knowledge of object-oriented C++ programming at the beginner/intermediate level. You'll quickly apply your programming knowledge to these new programming concepts.

In this book, Murray and Pappas will guide you through a solid integrated understanding of the latest STL (Standard Template Library) concepts couple with MFC's (Microsoft Foundation Class library) programming concepts that apply to both Windows 98 and Windows 2000.

The first six chapters deal exclusively with the STL. You'll learn terms, definitions and reasons for using the STL. Many command line examples will teach new programming concepts in simple applications.

In the next six chapters, you'll learn how to develop object-oriented MFC Windows applications. It's all here-wizards, icons, cursors, menus, dialog boxes and more. When you complete this group of chapters, you'll have a solid understanding of object-oriented programming under Windows.

In the final four chapters, STL concepts from the first six chapters are integrated with MFC Windows applications, from the second six chapters, to build robust MFC Windows applications using the STL. When you complete these four chapters, you understand how well both the STL and MFC integrate together to produce powerfulnewapplications.

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews

Visual C++ Templates 1 out of 5 based on 0 ratings. 1 reviews.
Guest More than 1 year ago
The back cover description leads one to believe that the focus of the book is application development in Visual C++, and that substantial usage examples of STL integrated with MFC are provided. In actual fact, the book is a rather dry dissertation on STL and Standard C++ headers, sometimes directed toward programmers making the transition from procedural languages to OO, sometimes toward complete programming novices, and yet other times (although infrequently) toward experienced C++ programmers. Individual templates are introduced by providing laundry lists of the methods implemented in the templates. Brief text descriptions of some of the methods follow. Usage examples (except for two) are command line programs using cin / cout for I/O. The two examples that actually are Windows applications are trivial (one plots Fourier Transforms, the other plots phasors). The templates used in these two examples are 'vector' and 'complex;' the actual code takes up a couple of pages. Overall, the book is not very helpful. STL and C++ Standard headers are described in other more readable, less expensive books. This book neither relates STL to the Microsoft environment in a meaningful way, nor provides any added value to the reader.