当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

《C++程序设计》课程教学资源(参考资料)C++ Programming ISO/IEC 14882 2003(规范文档)INTERNATIONAL STANDARD(Second edition)

资源类别:文库,文档格式:PDF,文档页数:784,文件大小:2.35MB,团购合买
点击下载完整版文档(PDF)

INTERNATIONAL ISO/IEC STANDARD 14882 Second edition 2D03.1015 Programming languages-C++ Langages de progremmation-C++ Adoptod by INCIT8 (nterNational Commltoe for Imformation Technology Standarda)as an American Nationel Standard. Date of ANSI Approva:12/292003 Publishod by Amnrican National Standards Insthute. 25 West 43rd Street,New York New York 10036 Copyright 2003 by Information Technology Industry Council OTI). All rights reserved. These materials are subject to copyright claims of Intemational Standardization Organization (ISO).Inlemnstional Electrotechncal Commssion (EC).American Natonl Standards Institute (ANSI),and inomation Technology Industry Council (I).Not for resale.No part of this pubicstion may be reproduced in any form,induding an eledtronic retrieval system,without the pror written pemmission of IT.Al requests pertaning to this standard should be submted to ITl,1250 Eye Street NW, Washington,DC 20006. Printed in the United Stales of America ISO IEC Refarence number 1S0MEG148822003(目 ISOMEC 2003

BC Reference number ISO/IEC 14882:2003(E) INTERNATIONAL STANDARD ISO/IEC 14882 Second edition 2003-10-15 Programming languages — C++ Langages de programmation — C++ Adopted by INCITS (InterNational Committee for Information Technology Standards) as an American National Standard. Date of ANSI Approval: 12/29/2003 Published by American National Standards Institute, 25 West 43rd Street, New York, New York 10036 Copyright 2003 by Information Technology Industry Council (ITI). All rights reserved. These materials are subject to copyright claims of International Standardization Organization (ISO), International Electrotechnical Commission (IEC), American National Standards Institute (ANSI), and Information Technology Industry Council (ITI). Not for resale. No part of this publication may be reproduced in any form, including an electronic retrieval system, without the prior written permission of ITI. All requests pertaining to this standard should be submitted to ITI, 1250 Eye Street NW, Washington, DC 20005. Printed in the United States of America

1S01EC14882:2003(E) Contents I Gereral 1.1 Scope..... 1.2 Normative references. 1.3 Terms and defiritions. 1.3.1 argument......... 1.32 dap0 she messap买 133 dynamic type. 2 1.34 ill-formed program 2 135 mplementaton-defined behavor 136 implementation limits. 137 locale-specific behavior 2 1.3.8 multibyte character.... 1.3.9 parameter 1.3.10 signature........ 444335* 2 13.11 i加ype 1.3.12 urdefined behavice.... 2 13.13 urspecified behavioc..... 13.14 well-formed program..... 1.4 Implementation compliance. 15 Stnucture of this Internotional Standard .4 1.6 Symtax notation 17 The C++memory model 1.8 The Cl abject model. 1.9 Program executicn 10NFC2083一AMig4swd 带

ISO/IEC 14882:2003(E) © ISO/IEC 2003 — All rights reserved iii Contents 1 General ........................................................................................................................................................1 1.1 Scope........................................................................................................................................................1 1.2 Normative references ...............................................................................................................................1 1.3 Terms and definitions .........................................................................................................................................1 1.3.1 argument ...............................................................................................................................................1 1.3.2 diagnostic message ...............................................................................................................................2 1.3.3 dynamic type .........................................................................................................................................2 1.3.4 ill-formed program................................................................................................................................2 1.3.5 implementation-defined behavior .........................................................................................................2 1.3.6 implementation limits ...........................................................................................................................2 1.3.7 locale-specific behavior ........................................................................................................................2 1.3.8 multibyte character ...............................................................................................................................2 1.3.9 parameter ..............................................................................................................................................2 1.3.10 signature ..............................................................................................................................................2 1.3.11 static type ............................................................................................................................................2 1.3.12 undefined behavior .............................................................................................................................2 1.3.13 unspecified behavior ...........................................................................................................................3 1.3.14 well-formed program ..........................................................................................................................3 1.4 Implementation compliance.....................................................................................................................3 1.5 Structure of this International Standard ...................................................................................................4 1.6 Syntax notation ........................................................................................................................................4 1.7 The C + + memory model ...........................................................................................................................4 1.8 The C + + object model ..............................................................................................................................4 1.9 Program execution ...................................................................................................................................5

1S01EC148822003(E) 1.10 Acknowledgments 2 Lexical conventions.. 9 2.1 Phases of translation 9 2.2 Character sets. 10 23Trg写hque85 2.4 Preprocessing tokens ,11 2.5 Ahemative tokens.. 12 2.6 Tokents 12 2.7 Comments........ 2.8 Header names. 13 2.9 Preprocessing numbers. 13 2.10 Identifiers... 13 2.11 Keywords. .14 2.12 Operators and punctuators 2.13 Literals 2.13.I Integer literals.. .15 2.13.2 Character literals ,16 2.13.3 Floating litcrals .18 2.13.4 String lierals... .19 2.13.5 Boolean literals .19 3 Basic concepts..... 21 3.1 Declarations and definitions. 21 3.2 One definition rule. 22 3.3 Declarative regions and scopes 24 3.3.1 Point of declaration 25 3.3.2 Local scope....... 26 3.3.3 Function procotype scope 26 3.3.4 Function scope.. 27 3.3.5 Namespace scope 27 3.3.6 Class scope..... 27 3.3.7 Name hiding 444444444444444444444444444 28 3.4 Name lookup.... 9 3.4.1 Ungusalified name lookup 29 3.4.2 Argument-dependent name lookup. .32 3.4.3 Qulified name lookup .34 SOEC 2003-Al rights neserved

ISO/IEC 14882:2003(E) iv © ISO/IEC 2003 — All rights reserved 1.10 Acknowledgments .................................................................................................................................8 2 Lexical conventions ....................................................................................................................................9 2.1 Phases of translation ................................................................................................................................9 2.2 Character sets .........................................................................................................................................10 2.3 Trigraph sequences ................................................................................................................................11 2.4 Preprocessing tokens .............................................................................................................................11 2.5 Alternative tokens ..................................................................................................................................12 2.6 Tokens....................................................................................................................................................12 2.7 Comments ..............................................................................................................................................12 2.8 Header names .........................................................................................................................................13 2.9 Preprocessing numbers ..........................................................................................................................13 2.10 Identifiers .............................................................................................................................................13 2.11 Keywords .............................................................................................................................................14 2.12 Operators and punctuators ...................................................................................................................15 2.13 Literals .................................................................................................................................................15 2.13.1 Integer literals ...................................................................................................................................15 2.13.2 Character literals ...............................................................................................................................16 2.13.3 Floating literals .................................................................................................................................18 2.13.4 String literals .....................................................................................................................................19 2.13.5 Boolean literals .................................................................................................................................19 3 Basic concepts ..........................................................................................................................................21 3.1 Declarations and definitions ..................................................................................................................21 3.2 One definition rule .................................................................................................................................22 3.3 Declarative regions and scopes ..............................................................................................................24 3.3.1 Point of declaration .............................................................................................................................25 3.3.2 Local scope .........................................................................................................................................26 3.3.3 Function prototype scope ....................................................................................................................26 3.3.4 Function scope ....................................................................................................................................27 3.3.5 Namespace scope ................................................................................................................................27 3.3.6 Class scope..........................................................................................................................................27 3.3.7 Name hiding........................................................................................................................................28 3.4 Name lookup ..........................................................................................................................................29 3.4.1 Unqualified name lookup ...................................................................................................................29 3.4.2 Argument-dependent name lookup .....................................................................................................32 3.4.3 Qualified name lookup .......................................................................................................................34

IS01EC14882:2003(目 3.43.】Cas8mem6rs 35 3.432 Namespace members. 35 3.4.4 Elaborated type specifiers 39 345 Clacss memtber aceess 40 3.4.6 Using-directives and namespoce aliases 41 35 Progran and linkage 4 3.6 Start and termination. 43 36.1 Main function 43 3.6 2 Initialization of non-local objects...... 4 563 Temmination 45 37S1 orage d国0n 46 3.7.1 Static storage duration.. 6 3.7 2 Automatic storage duration 46 3.73 Dynammic sorage duration. 7 373.】Allocation functi0s. 7 3.7.3 2 Deallocation functions 48 3.74 Duration of sub-objects 4移 3.8 Object Lifetime. 49 39Ty05. 51 3.9.1 Fundamental types 53 592 Compound types 55 3.9 3 CV-qualifiers 55 3.10 Lvalues and rvalues.. 4 Standard conversions.. 59 4.1 Lvalue-to-rvalue conversio....... .59 42 Array-to-pointer conversion .60 4.3 Function-to-pointer conversion .60 4.4 Qualification comversions. 0 4.5 Integral promotions 61 4.6 Floating point promotion. 61 4.7 Integral cooversions.. 6位 4.8 Floating point comversions 62 4.9 Floating-imegral conversions 2 4.10 Pointer comversions.. 62 4.11 Pointer to member conversions. 63 。50EC2003-Mg修eserved

ISO/IEC 14882:2003(E) © ISO/IEC 2003 — All rights reserved v 3.4.3.1 Class members .................................................................................................................................35 3.4.3.2 Namespace members .......................................................................................................................35 3.4.4 Elaborated type specifiers ...................................................................................................................39 3.4.5 Class member access ..........................................................................................................................40 3.4.6 Using-directives and namespace aliases .............................................................................................41 3.5 Program and linkage ..............................................................................................................................41 3.6 Start and termination..............................................................................................................................43 3.6.1 Main function......................................................................................................................................43 3.6.2 Initialization of non-local objects .......................................................................................................44 3.6.3 Termination.........................................................................................................................................45 3.7 Storage duration .....................................................................................................................................46 3.7.1 Static storage duration ........................................................................................................................46 3.7.2 Automatic storage duration.................................................................................................................46 3.7.3 Dynamic storage duration ...................................................................................................................47 3.7.3.1 Allocation functions.........................................................................................................................47 3.7.3.2 Deallocation functions .....................................................................................................................48 3.7.4 Duration of sub-objects.......................................................................................................................48 3.8 Object Lifetime ......................................................................................................................................49 3.9 Types......................................................................................................................................................52 3.9.1 Fundamental types ..............................................................................................................................53 3.9.2 Compound types .................................................................................................................................55 3.9.3 CV-qualifiers ......................................................................................................................................55 3.10 Lvalues and rvalues .............................................................................................................................56 4 Standard conversions ................................................................................................................................59 4.1 Lvalue-to-rvalue conversion ..................................................................................................................59 4.2 Array-to-pointer conversion ..................................................................................................................60 4.3 Function-to-pointer conversion .............................................................................................................60 4.4 Qualification conversions ......................................................................................................................60 4.5 Integral promotions ................................................................................................................................61 4.6 Floating point promotion .......................................................................................................................61 4.7 Integral conversions ...............................................................................................................................62 4.8 Floating point conversions .....................................................................................................................62 4.9 Floating-integral conversions ................................................................................................................62 4.10 Pointer conversions ..............................................................................................................................62 4.11 Pointer to member conversions ...........................................................................................................63

IS01EC148822003E) 4.12 Boolean conversions 63 5 Expressicns..... 65 5.1 Primary expressions 66 5.2 Poostfi expressions 68 5.2.1 Subscripting 68 5.2.2 Function call 68 52.3 Explicit type conversion (functional notation) 70 5.24 Pseudo destructor call 70 52.5 Class member access 70 5.2.6 Inerement and decrement 71 5.2.7 Dynamic cast 72 528 Type identification. 5.2.9 Static cast...... 7 5.2.10 Reinterpret cast 52.11 Const c城. 76 5.3 Unary expressions. 净 5.3.1 Unary operators. 78 5.3.2 Increment and decrement 79 5.3.3S20of 79 5.3.4New 8 5.3.5 Delete 83 5.4 Explicit type conversion (cast notation) 84 5.5 Pointer-to-member operators. .85 5.6 Multiplicative operatoes 85 5.7 Additive operators 86 5.8 Shift operators....... 87 5.9 Relational operators. 87 5.10 Equality operators 88 5.11 Bitwise AND operator 89 5.12 Bitwise exclusive OR operafor 5.13 Batwise inclusive OR operator 89 5.14 Logical AND operator 89 5.15 Logical OR operator. 90 5.16 Conditional operator. 90 5.17 Assignment operators 91 ISOEC0a如一相htws4ned

ISO/IEC 14882:2003(E) vi © ISO/IEC 2003 — All rights reserved 4.12 Boolean conversions ............................................................................................................................63 5 Expressions ...............................................................................................................................................65 5.1 Primary expressions ...............................................................................................................................66 5.2 Postfix expressions ................................................................................................................................68 5.2.1 Subscripting ........................................................................................................................................68 5.2.2 Function call .......................................................................................................................................68 5.2.3 Explicit type conversion (functional notation) ...................................................................................70 5.2.4 Pseudo destructor call .........................................................................................................................70 5.2.5 Class member access ..........................................................................................................................70 5.2.6 Increment and decrement ....................................................................................................................71 5.2.7 Dynamic cast ......................................................................................................................................72 5.2.8 Type identification ..............................................................................................................................73 5.2.9 Static cast ............................................................................................................................................74 5.2.10 Reinterpret cast .................................................................................................................................75 5.2.11 Const cast ..........................................................................................................................................76 5.3 Unary expressions ..................................................................................................................................78 5.3.1 Unary operators...................................................................................................................................78 5.3.2 Increment and decrement ....................................................................................................................79 5.3.3 Sizeof ..................................................................................................................................................79 5.3.4 New .....................................................................................................................................................80 5.3.5 Delete ..................................................................................................................................................83 5.4 Explicit type conversion (cast notation) ................................................................................................84 5.5 Pointer-to-member operators .................................................................................................................85 5.6 Multiplicative operators .........................................................................................................................85 5.7 Additive operators .................................................................................................................................86 5.8 Shift operators ........................................................................................................................................87 5.9 Relational operators ...............................................................................................................................87 5.10 Equality operators ................................................................................................................................88 5.11 Bitwise AND operator ..........................................................................................................................89 5.12 Bitwise exclusive OR operator .............................................................................................................89 5.13 Bitwise inclusive OR operator .............................................................................................................89 5.14 Logical AND operator ..........................................................................................................................89 5.15 Logical OR operator .............................................................................................................................90 5.16 Conditional operator ............................................................................................................................90 5.17 Assignment operators ..........................................................................................................................91

1s01EC14882:2003(曰 5.18 Comma operator 492 5.19 Constant expressions 1972 6 Statements. 495 6.1 Labeled statement 95 62 Expression statement 95 6.3 Compound staement or block 95 64 Selectiont staterent.... 9% 6A.1The1 statemen减 97 64 2 The awiteh statement 65 Iteration statements. 97 6.5.1 The while statement 498 6.52 The do statement 98 65 3 The for statement 99 6.6 Jump staements. .99 6.6.1 The break statement 444444444444444444444444 444444444444444444 .99 6.62 The continue staement 4100 663 The geturn statement ,100 664 The goto staement .100 6.7 Declaration statement .100 6.8 Ambiguity resolution. 7 Declarations .103 7.1 Specifiers..... 7.1.1 Storage elass specifiers 105 7.12 Function specifiers. .106 7.13 The typedef specifier. 107 7.1.4 The friond specifier 7.1 5 Type specifiers 7.15.1 The cr-qwnlfiers. .109 7.152 Simple type specifiers. 7.15 3 Elaborated type specifiers. 72 Enumeration declaratioes. 112 7.3 Namespaces. 14 7.3.1 Namespace definition 114 7.3.1.1 Unnamed namespaces. 115 7.3.1.2 Namnespace member definitices 4444444444444444444444444 .115 7.32 Namespace alias .117 7.33 The us ing declaration 117 734 Using directive. .123 7.4 The asn declaration 126 QIS0EC2003一All rights reserved

ISO/IEC 14882:2003(E) © ISO/IEC 2003 — All rights reserved vii 5.18 Comma operator ..................................................................................................................................92 5.19 Constant expressions ...........................................................................................................................92 6 Statements .................................................................................................................................................95 6.1 Labeled statement ..................................................................................................................................95 6.2 Expression statement .............................................................................................................................95 6.3 Compound statement or block ...............................................................................................................95 6.4 Selection statements...............................................................................................................................96 6.4.1 The if statement ................................................................................................................................97 6.4.2 The switch statement ......................................................................................................................97 6.5 Iteration statements ................................................................................................................................97 6.5.1 The while statement .........................................................................................................................98 6.5.2 The do statement ................................................................................................................................98 6.5.3 The for statement..............................................................................................................................99 6.6 Jump statements .....................................................................................................................................99 6.6.1 The break statement .........................................................................................................................99 6.6.2 The continue statement................................................................................................................100 6.6.3 The return statement ....................................................................................................................100 6.6.4 The goto statement .........................................................................................................................100 6.7 Declaration statement ..........................................................................................................................100 6.8 Ambiguity resolution ...........................................................................................................................101 7 Declarations ............................................................................................................................................103 7.1 Specifiers .............................................................................................................................................104 7.1.1 Storage class specifiers .....................................................................................................................105 7.1.2 Function specifiers ............................................................................................................................106 7.1.3 The typedef specifier....................................................................................................................107 7.1.4 The friend specifier ......................................................................................................................108 7.1.5 Type specifiers ..................................................................................................................................108 7.1.5.1 The cv-qualifiers............................................................................................................................109 7.1.5.2 Simple type specifiers ....................................................................................................................110 7.1.5.3 Elaborated type specifiers ..............................................................................................................111 7.2 Enumeration declarations ....................................................................................................................112 7.3 Namespaces .........................................................................................................................................114 7.3.1 Namespace definition .......................................................................................................................114 7.3.1.1 Unnamed namespaces ....................................................................................................................115 7.3.1.2 Namespace member definitions .....................................................................................................115 7.3.2 Namespace alias ................................................................................................................................117 7.3.3 The using declaration ....................................................................................................................117 7.3.4 Using directive ..................................................................................................................................123 7.4 The asm declaration ............................................................................................................................126

1S01EC148822003E) 7.5 Linkage specifications 126 8 Declaraors... 13引 8.1 Type names... 132 8.2 Ambiguity resolution. 132 8.3 Meaning of declarators 134 8.3.1 Poimers 135 8.3.2 References....... 135 8.3.3 Poirters to members m136 8.3.4 T544 137 835 Functionts....... 138 8.3.6 Default argumments. 141 8.4 Function definitions 144 8.5 Initializers..... 145 8.5.1Ag8r9ge5 147 8.5.2 Character ararys 150 8.3.3 References......... 130 9 Classes. 153 9.1 Class names.. 153 9.2 Class members......... 155 9.3 Member functions. 157 9.3.I Noretatic member functiones 158 932 The this pointer 160 9.4Stl民nembers. 160 9.4.1 Static member functions 16 942 Statie data members. 161 9.5 Unions.… 162 9.6 Bat-fields 163 9.7 Nested elass declarations 16d 9.8 Local class declarations 165 9.9 Nested type names .166 10 Derived classes...... 167 10.I Multiple base classes .168 10.2 Member name lookup 169 10.3 Virtual functions. 172 v ●50EG20ag-A相ghts nesenved

ISO/IEC 14882:2003(E) viii © ISO/IEC 2003 — All rights reserved 7.5 Linkage specifications .........................................................................................................................126 8 Declarators ..............................................................................................................................................131 8.1 Type names ..........................................................................................................................................132 8.2 Ambiguity resolution ...........................................................................................................................132 8.3 Meaning of declarators ........................................................................................................................134 8.3.1 Pointers .............................................................................................................................................135 8.3.2 References .........................................................................................................................................135 8.3.3 Pointers to members .........................................................................................................................136 8.3.4 Arrays ...............................................................................................................................................137 8.3.5 Functions...........................................................................................................................................138 8.3.6 Default arguments .............................................................................................................................141 8.4 Function definitions .............................................................................................................................144 8.5 Initializers ............................................................................................................................................145 8.5.1 Aggregates ........................................................................................................................................147 8.5.2 Character arrays ................................................................................................................................150 8.5.3 References .........................................................................................................................................150 9 Classes ....................................................................................................................................................153 9.1 Class names .........................................................................................................................................153 9.2 Class members .....................................................................................................................................155 9.3 Member functions ................................................................................................................................157 9.3.1 Nonstatic member functions .............................................................................................................158 9.3.2 The this pointer .............................................................................................................................160 9.4 Static members.....................................................................................................................................160 9.4.1 Static member functions ...................................................................................................................161 9.4.2 Static data members ..........................................................................................................................161 9.5 Unions ..................................................................................................................................................162 9.6 Bit-fields ..............................................................................................................................................163 9.7 Nested class declarations .....................................................................................................................164 9.8 Local class declarations .......................................................................................................................165 9.9 Nested type names ...............................................................................................................................166 10 Derived classes .....................................................................................................................................167 10.1 Multiple base classes .........................................................................................................................168 10.2 Member name lookup ........................................................................................................................169 10.3 Virtual functions ................................................................................................................................172

1S01EC14882:2003(曰 10.4 Abstraet clases 1176 11 Member access control 11.】Access specit6ers 180 112 Accessibility of base classes and base class members. ,181 113 Access declar瑞ons 182 114 Friends.. 183 115 Protected member acoess .185 116 Access to virtuall functions.. 187 11.7 Multiple access .188 11.8 Nested classes 188 12 Special member functions. .189 12.1 Constructors. 189 12 2 Temporary objects 123 Conversions 111192 12 3.1 Comversion by constructor. 4,193 123.2 Comversion finctions 124 Destructors 125 Free store.. .198 12.6 Initialization 12.6.1 Expliit initialization 200 1262 Initializing bases and members. 201 12.7 Construction and destruction 204 12.8 Copying class objeets 44444207 13 Overloading. 213 13.1 Overlcadable declarations 213 132 Declaration matching 44215 13.3 Overload resolution. .216 13.3.1 Candidate functions and argumment lists 217 13 3.11 Function call syntax.. …218 13_3.1.1.1 Call to named function. 218 13.3.1.1.2 Call to object of class type........ 219 13.3.12 Opermtors in expressices....... 220 ISOnEC 2003-All rights reserved

ISO/IEC 14882:2003(E) © ISO/IEC 2003 — All rights reserved ix 10.4 Abstract classes ..................................................................................................................................176 11 Member access control .........................................................................................................................179 11.1 Access specifiers ................................................................................................................................180 11.2 Accessibility of base classes and base class members .......................................................................181 11.3 Access declarations ............................................................................................................................182 11.4 Friends ...............................................................................................................................................183 11.5 Protected member access ...................................................................................................................186 11.6 Access to virtual functions.................................................................................................................187 11.7 Multiple access ..................................................................................................................................188 11.8 Nested classes ....................................................................................................................................188 12 Special member functions.....................................................................................................................189 12.1 Constructors .......................................................................................................................................189 12.2 Temporary objects .............................................................................................................................191 12.3 Conversions .......................................................................................................................................192 12.3.1 Conversion by constructor ..............................................................................................................193 12.3.2 Conversion functions ......................................................................................................................194 12.4 Destructors .........................................................................................................................................195 12.5 Free store ...........................................................................................................................................198 12.6 Initialization .......................................................................................................................................199 12.6.1 Explicit initialization ......................................................................................................................200 12.6.2 Initializing bases and members .......................................................................................................201 12.7 Construction and destruction .............................................................................................................204 12.8 Copying class objects ........................................................................................................................207 13 Overloading ..........................................................................................................................................213 13.1 Overloadable declarations..................................................................................................................213 13.2 Declaration matching .........................................................................................................................215 13.3 Overload resolution ...........................................................................................................................216 13.3.1 Candidate functions and argument lists ..........................................................................................217 13.3.1.1 Function call syntax .....................................................................................................................218 13.3.1.1.1 Call to named function..............................................................................................................218 13.3.1.1.2 Call to object of class type ........................................................................................................219 13.3.1.2 Operators in expressions ..............................................................................................................220

1S01EC148822003(E) 13.3.1.3 Initialization by constructor. 222 13.3.14 Copy-initialization ofelass by user-defined conversion 222 133.15 Intialization by conversion function.......... 222 13.3.16 Initialization by conversion function for direct reference binding. 223 13.3.2 Viable functions 223 13.3.3 Best Viable Function 223 13.3.3.1 Implicit conversion sequences.. 225 13.33.1.1 Standard conversion sequences 227 13.3.3.1 2 User-defined conversion sequences......... 227 13.3.3.1.3 Ellipsis comversion sequences............. 228 13.3.3.1.4 Reference binding 228 13.3.3.2 Ranking implicit coemversion sequences 228 13.4 Address of overloaded function. 230 13.5 Overloaded operators. 232 13.5.1 Unary operators.. 233 13.5.2 Binary operators. 233 13.5.3 Assignment 233 13.5.4 Function call 234 13.5.5 Subscnpeing...... 234 13.56 Class member access. 234 13.5.7 Increment and deeremen 234 136Bun业-operators 235 14 Templates. 239 14.1 Template parameters. 240 14.2 Names of template specializntions. 242 14.3 Template arguments. 244 14.3.1 Template type arguments 245 14.3.2 Template noe-type arguments 246 14.3.3 Template template arguments. 248 14.4 Type equivalence. 248 14.5 Template declarations. 249 14.5.1 Class templaces 249 14.5.1.1 Member functions of class templates......... 249 14 5.1 2 Member classes of class templales.... 250 14.5.1.3 Static data members of class templates..... 250 14.5.2 Member templales 中年年车中年年4444411年44111车4年车44年 251 14.5.3 Friends ....... 252 14.54 Class template partial specializations. 254 14.54.1 Matching of class template partial specializations 256 14.5.4.2 Partial ordering of elass template specializations 44444444444444444444444444 257 14.5.4.3 Members of class template specializations 257 14.5.$Function templates 258 14.5.5.1 Function template overloading 259 14.5.5.2 Partial ordering of function templaes..... 260 SOMEC 2003-Al rights neserved

ISO/IEC 14882:2003(E) x © ISO/IEC 2003 — All rights reserved 13.3.1.3 Initialization by constructor .........................................................................................................222 13.3.1.4 Copy-initialization of class by user-defined conversion..............................................................222 13.3.1.5 Initialization by conversion function ...........................................................................................222 13.3.1.6 Initialization by conversion function for direct reference binding ..............................................223 13.3.2 Viable functions ..............................................................................................................................223 13.3.3 Best Viable Function ......................................................................................................................223 13.3.3.1 Implicit conversion sequences .....................................................................................................225 13.3.3.1.1 Standard conversion sequences ................................................................................................227 13.3.3.1.2 User-defined conversion sequences ..........................................................................................227 13.3.3.1.3 Ellipsis conversion sequences...................................................................................................228 13.3.3.1.4 Reference binding .....................................................................................................................228 13.3.3.2 Ranking implicit conversion sequences.......................................................................................228 13.4 Address of overloaded function .........................................................................................................230 13.5 Overloaded operators .........................................................................................................................232 13.5.1 Unary operators...............................................................................................................................233 13.5.2 Binary operators..............................................................................................................................233 13.5.3 Assignment .....................................................................................................................................233 13.5.4 Function call ...................................................................................................................................234 13.5.5 Subscripting ....................................................................................................................................234 13.5.6 Class member access ......................................................................................................................234 13.5.7 Increment and decrement ................................................................................................................234 13.6 Built-in operators ...............................................................................................................................235 14 Templates ..............................................................................................................................................239 14.1 Template parameters ..........................................................................................................................240 14.2 Names of template specializations .....................................................................................................242 14.3 Template arguments...........................................................................................................................244 14.3.1 Template type arguments ................................................................................................................245 14.3.2 Template non-type arguments ........................................................................................................246 14.3.3 Template template arguments .........................................................................................................248 14.4 Type equivalence ...............................................................................................................................248 14.5 Template declarations ........................................................................................................................249 14.5.1 Class templates ...............................................................................................................................249 14.5.1.1 Member functions of class templates...........................................................................................249 14.5.1.2 Member classes of class templates ..............................................................................................250 14.5.1.3 Static data members of class templates........................................................................................250 14.5.2 Member templates ..........................................................................................................................251 14.5.3 Friends ............................................................................................................................................252 14.5.4 Class template partial specializations .............................................................................................254 14.5.4.1 Matching of class template partial specializations ......................................................................256 14.5.4.2 Partial ordering of class template specializations ........................................................................257 14.5.4.3 Members of class template specializations ..................................................................................257 14.5.5 Function templates ..........................................................................................................................258 14.5.5.1 Function template overloading ....................................................................................................259 14.5.5.2 Partial ordering of function templates .........................................................................................260

IS01EC14882:2003(曰 14.6 Name resolution. 261 146.1 Locally declared names 264 14.6 2 Dependent names 267 1462.1 Dependert type 268 14622 Type-dependent expressions. 268 14623 Value-dependent expressions 269 14.62.4 Dependent template arguments......... 269 14.6 3 Non-dependent names 444270 14.6.4 Dependent name resolution......... 270 14 6 4 1 Point of instantiation. 270 14.6.42 Candidale functions 271 1465 Friend names declared within a class template 4271 14.7 Template instantiation and specialization. 272 14.7.1 Implicit instantiation. 273 14.72 Explicit instantiation. 14.73 Explicit specialization. 277 148 Function template specializatioes... 282 14 8.I Explicit template argument specification 14.82 Template argument deduction..... 4283 285 14.821 Deducing template arguments from a function call 287 14822 Deducing template arguments taking the address of a function template 288 14.823 Dedueing comversion function templae arguments 4444444444444444444444444 288 14.8 24 Deducing template arguments from a type. 288 1483 Overload resolution ,293 15 Exoeption handling 297 15.1 Throwing an exception 29% 15 2 Constructors and destructors.. 300 15.3 Handling an exception. 444300 154 Exception specifications. 302 155 Special functions. 304 15 5.1 The terninate (function......... 304 1552 The unexpected()function.... 30S 1553 The uncaught_exception (function. 305 156 Exceptions and access 305 16 Preprocessing directives 307 16.1 Conditional inclusion 308 162 Source file inclusion .309 16.3 Macro replacemert 30 16.3.1 Argument substitutiomn 311 1632 The operator 16.33 The operalor 312 。50EC2003-Mg修eserved

ISO/IEC 14882:2003(E) © ISO/IEC 2003 — All rights reserved xi 14.6 Name resolution .................................................................................................................................261 14.6.1 Locally declared names ..................................................................................................................264 14.6.2 Dependent names ............................................................................................................................267 14.6.2.1 Dependent types...........................................................................................................................268 14.6.2.2 Type-dependent expressions ........................................................................................................268 14.6.2.3 Value-dependent expressions ......................................................................................................269 14.6.2.4 Dependent template arguments ....................................................................................................269 14.6.3 Non-dependent names.....................................................................................................................270 14.6.4 Dependent name resolution ............................................................................................................270 14.6.4.1 Point of instantiation ....................................................................................................................270 14.6.4.2 Candidate functions .....................................................................................................................271 14.6.5 Friend names declared within a class template ...............................................................................271 14.7 Template instantiation and specialization ..........................................................................................272 14.7.1 Implicit instantiation .......................................................................................................................273 14.7.2 Explicit instantiation .......................................................................................................................276 14.7.3 Explicit specialization .....................................................................................................................277 14.8 Function template specializations ......................................................................................................282 14.8.1 Explicit template argument specification .......................................................................................283 14.8.2 Template argument deduction ........................................................................................................285 14.8.2.1 Deducing template arguments from a function call .....................................................................287 14.8.2.2 Deducing template arguments taking the address of a function template ...................................288 14.8.2.3 Deducing conversion function template arguments.....................................................................288 14.8.2.4 Deducing template arguments from a type ..................................................................................288 14.8.3 Overload resolution ........................................................................................................................293 15 Exception handling ...............................................................................................................................297 15.1 Throwing an exception ......................................................................................................................298 15.2 Constructors and destructors..............................................................................................................300 15.3 Handling an exception .......................................................................................................................300 15.4 Exception specifications ....................................................................................................................302 15.5 Special functions ................................................................................................................................304 15.5.1 The terminate() function ........................................................................................................304 15.5.2 The unexpected() function ......................................................................................................305 15.5.3 The uncaught_exception() function ...................................................................................305 15.6 Exceptions and access ........................................................................................................................305 16 Preprocessing directives .......................................................................................................................307 16.1 Conditional inclusion .........................................................................................................................308 16.2 Source file inclusion ..........................................................................................................................309 16.3 Macro replacement ............................................................................................................................310 16.3.1 Argument substitution ....................................................................................................................311 16.3.2 The # operator ................................................................................................................................311 16.3.3 The ## operator ..............................................................................................................................312

点击下载完整版文档(PDF)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共784页,可试读40页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有