Lischner | Exploring C++ 11 | E-Book | sack.de
E-Book

E-Book, Englisch, 617 Seiten, eBook

Lischner Exploring C++ 11


2. Auflage 2014
ISBN: 978-1-4302-6194-0
Verlag: APRESS
Format: PDF
Kopierschutz: 1 - PDF Watermark

E-Book, Englisch, 617 Seiten, eBook

ISBN: 978-1-4302-6194-0
Verlag: APRESS
Format: PDF
Kopierschutz: 1 - PDF Watermark



Exploring C++ divides C++ up into bite-sized chunks that will help you learn the language one step at a time. Assuming no familiarity with C++, or any other C-based language, you’ll be taught everything you need to know in a logical progression of small lessons that you can work through as quickly or as slowly as you need. C++ can be a complicated language. Writing even the most straight-forward of programs requires you to understand many disparate aspects of the language and how they interact with one another. C++ doesn't lend itself to neat compartmentalization the way other languages do. Rather than baffle you with complex chapters explaining functions, classes and statements in isolation we’ll focus on teaching you how to achieve results. By learning a little bit of this and a little of that you’ll soon have amassed enough knowledge to be writing non-trivial programs and will have built a solid foundation of experience that puts those previously baffling concepts into context. In this fully-revised second edition of Exploring C++ , you’ll learn how to use the standard library early in the book. Next, you’ll learn to work with operators, objects and data-sources in increasingly realistic situations. Finally, you’ll start putting the pieces together to create sophisticated programs of your own design confident that you’ve built a firm base of experience from which to grow.
Lischner Exploring C++ 11 jetzt bestellen!

Zielgruppe


Popular/general


Autoren/Hrsg.


Weitere Infos & Material


1;Contents at a Glance;3
2;Contents;598
3;About the Author;614
4;About the Technical Reviewers;616
5;Acknowledgment;617
6;Introduction;7
7;EXPLORATION 1: Honing Your Tools;11
7.1;Ray’s Recommendations;11
7.1.1;Microsoft Windows;11
7.1.2;Macintosh OS X;12
7.1.3;Everyone Else;12
7.2;Read the Documentation;12
7.3;Your First Program;13
8;EXPLORATION 2: Reading C++ Code;18
8.1;Comments;19
8.2;Headers;19
8.3;Main Program;20
8.4;Variable Definitions;21
8.5;Statements;22
8.6;Output;23
9;EXPLORATION 3: Integer Expressions;24
10;EXPLORATION 4: Strings;30
11;EXPLORATION 5: Simple Input;35
12;EXPLORATION 6: Error Messages;40
12.1;Misspelling;41
12.2;Bogus Character;42
12.3;Unknown Operator;43
12.4;Unknown Name;43
12.5;Symbol Errors;44
12.6;Fun with Errors;44
13;EXPLORATION 7: For Loops;45
13.1;Bounded Loops;45
13.1.1;Initialization;46
13.1.2;Condition;47
13.1.3;Postiteration;47
13.1.4;How a for Loop Works;47
13.2;Your Turn;48
14;EXPLORATION 8: Formatted Output;49
14.1;The Problem;49
14.2;Field Width;50
14.3;Fill Character;51
14.4;std Prefix;52
14.5;Alignment;52
14.6;Exploring Formatting;53
14.7;Alternative Syntax;54
14.8;On Your Own;55
15;EXPLORATION 9: Arrays and Vectors;57
15.1;Vectors for Arrays;58
15.2;Vectors;58
15.3;Iterators;59
16;EXPLORATION 10: Algorithms and Iterators;61
16.1;Algorithms;61
16.2;Member Types;62
16.3;A Simpler Loop;63
16.4;Using Iterators and Algorithms;64
17;EXPLORATION 11: Increment and Decrement;67
17.1;Increment;67
17.2;Decrement;68
18;EXPLORATION 12: Conditions and Logic;72
18.1;I/O and bool;72
18.2;Boolean Type;73
18.3;Logic Operators;75
18.4;Old-Fashioned Syntax;76
18.5;Comparison Operators;76
19;EXPLORATION 13: Compound Statements;79
19.1;Statements;79
19.2;Local Definitions and Scope;82
19.3;Definitions in for Loop Headers;85
20;EXPLORATION 14: Introduction to File I/O;88
20.1;Reading Files;88
20.2;Writing Files;89
21;EXPLORATION 15: The Map Data Structure;92
21.1;Using Maps;93
21.2;Pairs;93
21.3;Searching in Maps;95
22;EXPLORATION 16: Type Synonyms;98
22.1;typedef Declarations;98
22.2;Common typedefs;99
22.3;Type Aliases;99
23;EXPLORATION 17: Characters;101
23.1;Character Type;101
23.2;Character I/O;103
23.3;Newlines and Portability;104
23.4;Character Escapes;105
24;EXPLORATION 18: Character Categories;106
24.1;Character Sets;106
24.2;Character Categories;108
24.3;Locales;109
25;Exploration 19: Case-Folding;112
25.1;Simple Cases;112
25.2;Harder Cases;113
26;EXPLORATION 20: Writing Functions;115
26.1;Functions;115
26.2;Function Call;117
26.3;Declarations and Definitions;117
26.4;Counting Words—Again;119
26.5;The main() Function;122
27;EXPLORATION 21: Function Arguments;123
27.1;Argument Passing;123
27.2;Pass-by-Reference;125
27.3;const References;127
27.4;const_iterator;129
27.5;Multiple Output Parameters;129
28;Exploration 22: Using Algorithms;130
28.1;Transforming Data;130
28.2;Predicates;135
28.3;Other Algorithms;137
29;Exploration 23: Unnamed Functions;140
29.1;Lambdas;140
29.2;Naming an Unnamed Function;142
29.3;Capturing Local Variables;142
29.4;const Capture;144
29.5;Return Type;145
30;Exploration 24: Overloading Function Names;147
30.1;Overloading;147
30.1.1;bool is_alpha(char ch);149
30.1.2;bool is_alpha(std::string const& str);149
30.1.3;char to_lower(char ch);149
30.1.4;std::string to_lower(std::string str);150
30.1.5;char to_upper(char ch);150
30.1.6;std::string to_upper(std::string str);150
31;Exploration 25: Big and Little Numbers;153
31.1;The Long and Short of It;153
31.1.1;Long Integers;154
31.1.2;Short Integers;154
31.2;Integer Literals;155
31.3;Byte-Sized Integers;156
31.4;Type Casting;157
31.5;Make Up Your Own Literals;158
31.6;Integer Arithmetic;159
31.7;Overload Resolution;160
32;Exploration 26: Very Big and Very Little Numbers;162
32.1;Floating-Point Numbers;162
32.2;Floating-Point Literals;163
32.3;Floating-Point Traits;164
32.4;Floating-Point I/O;165
33;Exploration 27: Documentation;169
33.1;Doxygen;169
33.2;Structured Comments;169
33.3;Documentation Tags and Markdown;170
33.4;Using Doxygen;175
33.4.1;@b word;170
33.4.2;@brief one-sentence-description;170
33.4.3;@c word;170
33.4.4;@em word;170
33.4.5;@file file name;170
33.4.6;@link entity text @endlink;170
33.4.7;@mainpage title;171
33.4.8;@p name;171
33.4.9;@par title;171
33.4.10;@param name description;171
33.4.11;@post postcondition;171
33.4.12;@pre precondition;171
33.4.13;@return description;171
33.4.14;@see xref;171
33.4.15;@ &, @@, @\, @%, @<;172
34;Exploration 28: Project 1: Body-Mass Index;176
34.1;Hints;177
35;Exploration 29: Custom Types;178
35.1;Defining a New Type;178
35.2;Member Functions;179
35.3;Constructors;182
35.4;Overloading Constructors;184
36;Exploration 30: Overloading Operators;185
36.1;Comparing Rational Numbers;185
36.2;Arithmetic Operators;188
36.3;Math Functions;191
37;Exploration 31: Custom I/O Operators;194
37.1;Input Operator;194
37.2;Output Operator;195
37.3;Error State;196
38;Exploration 32: Assignment and Initialization;198
38.1;Assignment Operator;198
38.2;Constructors;199
38.3;Putting It All Together;200
39;Exploration 33: Writing Classes;205
39.1;Anatomy of a Class;205
39.2;Member Functions;206
39.3;Constructor;208
39.4;Defaulted and Deleted Constructors;212
40;Exploration 34: More About Member Functions;213
40.1;Revisiting Project 1;213
40.2;Const Member Functions;217
41;Exploration 35: Access Levels;220
41.1;Public vs. Private;220
41.2;class vs. struct;223
41.3;Plain Old Data;223
41.4;Public or Private ?;224
42;Exploration 36: Introduction to Object-Oriented Programming;229
42.1;Books and Magazines;229
42.2;Classification;230
42.3;Inheritance;232
42.4;Liskov’s Substitution Principle;233
42.5;Type Polymorphism;234
43;Exploration 37: Inheritance;235
43.1;Deriving a Class;235
43.2;Member Functions;238
43.3;Destructors;238
43.4;Access Level;242
43.5;Programming Style;243
44;Exploration 38: Virtual Functions;244
44.1;Type Polymorphism;244
44.2;Virtual Functions;247
44.3;References and Slices;250
44.4;Pure Virtual Functions;251
44.5;Virtual Destructors;251
45;Exploration 39: Classes and Types;252
45.1;Classes vs. typedefs;252
45.2;Value Types;255
45.2.1;Copying;255
45.2.2;Assigning;255
45.2.3;Moving;256
45.2.4;Comparing;257
45.3;Resource Acquisition Is Initialization;260
46;EXPLORATION 40: Declarations and Definitions;262
46.1;Declaration vs. Definition;262
46.2;inline Functions;264
46.3;Variable Declarations and Definitions;265
46.4;Static Variables;267
46.5;Static Data Members;269
46.6;Declarators;271
47;EXPLORATION 41: Using Multiple Source Files;272
47.1;Multiple Source Files;272
47.2;Declarations and Definitions;273
47.3;#include Files;276
47.3.1;Quotes and Brackets;277
47.3.2;Nested #include Directives;277
47.3.3;Include Guards;278
47.3.4;Forward Declarations;280
47.3.5;Documentation;280
47.4;extern Variables;282
47.5;inline Functions;283
47.6;One-Definition Rule;284
48;EXPLORATION 42: Function Objects;286
48.1;The Function Call Operator;286
48.2;Function Objects;288
49;EXPLORATION 43: Useful Algorithms;290
49.1;Searching;290
49.1.1;Linear Search Algorithms;290
49.1.2;Binary Search Algorithms;295
49.2;Comparing;298
49.3;Rearranging Data;300
49.4;Copying Data;302
49.5;Deleting Elements;302
49.6;Iterators;303
50;EXPLORATION 44: Iterators;304
50.1;Kinds of Iterators;304
50.1.1;Input Iterators;305
50.1.2;Output Iterators;305
50.1.3;Forward Iterators;305
50.1.4;Bidirectional Iterators;305
50.1.5;Random Access Iterators;306
50.2;Working with Iterators;307
50.3;const_iterator vs. const iterator;308
50.4;Error Messages;310
50.5;Specialized Iterators;311
51;EXPLORATION 45: Exceptions;314
51.1;Introducing Exceptions;314
51.2;Catching Exceptions;316
51.3;Throwing Exceptions;317
51.4;Program Stack;318
51.5;Standard Exceptions;322
51.6;I/O Exceptions;323
51.7;Custom Exceptions;324
51.8;Don’t Throw Exceptions;326
51.9;Exceptional Advice;327
52;EXPLORATION 46: More Operators;328
52.1;Conditional Operator;328
52.2;Short-Circuit Operators;330
52.3;Comma Operator;330
52.4;Arithmetic Assignment Operators;333
52.5;Increment and Decrement;334
53;Exploration 47: Project 2: Fixed-Point Numbers;338
53.1;value_type;338
53.2;places;338
53.3;places10;338
53.4;fixed(?);338
53.5;fixed(value_type integer, value_type fraction);338
53.6;fixed(double val);339
53.7;to_string(?);339
53.8;round(?);339
53.9;integer(?);339
53.10;fraction(?);339
54;Exploration 48: Function Templates;343
54.1;Generic Functions;343
54.2;Using Function Templates;344
54.3;Writing Function Templates;345
54.4;Template Parameters;347
54.5;Template Arguments;348
54.6;Declarations and Definitions;350
54.7;Member Function Templates;350
55;Exploration 49: Class Templates;352
55.1;Parameterizing a Type;352
55.2;Parameterizing the rational Class;353
55.3;Using Class Templates;355
55.4;Overloaded Operators;356
55.5;Mixing Types;358
56;Exploration 50: Template Specialization;360
56.1;Instantiation and Specialization;360
56.2;Custom Comparators;363
56.3;Specializing Function Templates;364
56.4;Traits;365
57;Exploration 51: Partial Template Specialization;368
57.1;Degenerate Pairs;368
57.2;Partial Specialization;369
57.3;Partially Specializing Function Templates;370
57.4;Value Template Parameters;370
58;Exploration 52: Names and Namespaces;373
58.1;Namespaces;373
58.2;Nested Namespaces;376
58.3;Global Namespace;378
58.4;The std Namespace;378
58.5;Using Namespaces;379
58.5.1;The using Directive;379
58.5.2;The using Declaration;381
58.5.3;The using Declaration in a Class;384
58.6;Unnamed Namespaces;385
58.7;Name Lookup;385
59;Exploration 53: Containers;390
59.1;Properties of Containers;390
59.2;Member Types;391
59.2.1;value_type;391
59.2.2;key_type;391
59.2.3;reference;391
59.2.4;const_reference;392
59.2.5;iterator;392
59.2.6;const_iterator;392
59.2.7;size_type;392
59.3;What Can Go into a Container;392
59.4;Inserting and Erasing;393
59.4.1;Inserting in a Sequence Container;393
59.4.2;Erasing from a Sequence Container;394
59.4.3;Inserting in an Associative Container;395
59.4.4;Erasing from an Associative Container;396
59.4.5;Exceptions;396
59.5;Iterators and References;397
59.6;Sequence Containers;399
59.6.1;The array Class Template;401
59.6.2;The deque Class Template;402
59.6.3;The list Class Template;402
59.6.4;The vector Class Template;403
59.7;Associative Containers;404
60;Exploration 54: Locales and Facets;409
60.1;The Problem;409
60.2;Locales to the Rescue;410
60.3;Locales and I/O;411
60.4;Facets;411
60.5;Character Categories;413
60.6;Collation Order;418
61;Exploration 55: International Characters;420
61.1;Why Wide?;420
61.2;Using Wide Characters;420
61.3;Wide Strings;421
61.4;Wide Character I/O;423
61.5;Multi-Byte Character Sets;424
61.6;Unicode;425
61.7;Universal Character Names;426
61.8;Unicode Difficulties;427
62;Exploration 56: Text I/O;428
62.1;File Modes;428
62.2;String Streams;429
62.3;Text Conversion;435
63;Exploration 57: Project 3: Currency Type;441
64;Exploration 58: Pointers;442
64.1;A Programming Problem;442
64.2;The Solution;450
64.3;Addresses vs. Pointers;451
64.4;Dependency Graphs;452
65;Exploration 59: Dynamic Memory;455
65.1;Allocating Memory;455
65.2;Freeing Memory;456
65.3;Pointer to Nothing;456
65.4;Implementing Standard Containers;458
65.5;Adding Variables;459
65.6;Special Member Functions;466
66;Exploration 60: Moving Data with Rvalue References;470
66.1;Temporary Objects;470
66.2;Lvalues, Rvalues, and More;473
66.3;Implementing Move;474
66.4;Rvalue or Lvalue?;475
66.5;Special Member Functions;476
67;EXPLORATION 61: Exception-Safety;478
67.1;Memory Leaks;478
67.2;Exceptions and Dynamic Memory;480
67.3;Automatically Deleting Pointers;481
67.4;Exceptions and Constructors;484
68;EXPLORATION 62: Old-Fashioned Arrays;488
68.1;C-Style Arrays;488
68.2;Array Limitations;489
68.3;Dynamically Allocating an Array;490
68.4;The array Type;491
68.5;Multidimensional Arrays;491
68.6;C-Style Strings;492
68.7;Command-Line Arguments;492
68.8;Pointer Arithmetic;494
69;EXPLORATION 63: Smart Pointers;496
69.1;Revisiting unique_ptr;496
69.2;Copyable Smart Pointers;497
69.3;Smart Arrays;498
69.4;Pimpls;499
69.5;Iterators;504
70;Exploration 64: Working with Bits;505
70.1;Integer As a Set of Bits;505
70.2;Bitmasks;507
70.3;Shifting Bits;508
70.4;Safe Shifting with Unsigned Types;509
70.4.1;Signed and Unsigned Types;510
70.4.2;Unsigned Literals;511
70.4.3;Type Conversions;511
70.5;Overflow;515
70.6;Introducing Bitfields;516
70.7;Portability;517
70.8;The bitset Class Template;517
71;Exploration 65: Enumerations;520
71.1;Scoped Enumerations;520
71.2;Unscoped Enumerations;522
71.3;Strings and Enumerations;522
71.4;Revisiting Projects;524
72;Exploration 66: Multiple Inheritance;527
72.1;Multiple Base Classes;527
72.2;Virtual Base Classes;530
72.3;Java-Like Interfaces;532
72.4;Interfaces vs. Templates;534
72.5;Mix-Ins;536
72.5.1;Protected Access Level;537
73;EXPLORATION 67: Traits and Policies;539
73.1;Case Study: Iterators;539
73.2;Iterator Traits;542
73.3;Type Traits;543
73.4;Case Study: char_traits;543
73.5;Policy-Based Programming;545
74;EXPLORATION 68: Names, Namespaces, and Templates;552
74.1;Common Rules;552
74.2;Name Lookup in Templates;553
74.3;Three Kinds of Name Lookup;553
74.4;Member Access Operators;553
74.5;Qualified Name Lookup;555
74.6;Unqualified Name Lookup;557
74.7;Argument-Dependent Lookup;558
75;EXPLORATION 69: Overloaded Functions and Operators;561
75.1;Type Conversion;561
75.2;Review of Overloaded Functions;562
75.3;Overload Resolution;565
75.3.1;Ranking Functions;565
75.3.2;List Initialization;567
75.3.3;Tie-Breakers;567
75.4;Default Arguments;571
76;EXPLORATION 70: Metaprogramming;573
76.1;Use constexpr for Compile-Time Values;573
76.2;Variable-Length Template Argument Lists;575
76.3;Types as Values;578
76.4;Conditional Types;580
76.5;Checking Traits;581
76.6;Substitution Failure Is Not An Error (SFINAE);583
77;EXPLORATION 71: Project 4: Calculator;585
78;Index;586


Ray Lischner has a bachelor's degree in computer science from Caltech and a master's in computer science from Oregon State University. He worked as a software developer for a dozen years, at big and small companies across the U.S., using PL/I, C, C++, Delphi, Smalltalk, and various assembly languages on both large and small systems. He has been self-employed as a consultant, trainer, and author for the last 10 years. Ray taught computer science at Oregon State University for several years and specialized in teaching introductory computer programming. He taught courses in C and C++ and software engineering.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.