ANSI ISO IEC 14882-2003 Programming languages C++ (Adopted by INCITS)《INCITS采用的C++语言》.pdf

上传人:visitstep340 文档编号:437196 上传时间:2018-11-14 格式:PDF 页数:786 大小:2.35MB
下载 相关 举报
ANSI ISO IEC 14882-2003 Programming languages C++ (Adopted by INCITS)《INCITS采用的C++语言》.pdf_第1页
第1页 / 共786页
ANSI ISO IEC 14882-2003 Programming languages C++ (Adopted by INCITS)《INCITS采用的C++语言》.pdf_第2页
第2页 / 共786页
ANSI ISO IEC 14882-2003 Programming languages C++ (Adopted by INCITS)《INCITS采用的C++语言》.pdf_第3页
第3页 / 共786页
ANSI ISO IEC 14882-2003 Programming languages C++ (Adopted by INCITS)《INCITS采用的C++语言》.pdf_第4页
第4页 / 共786页
ANSI ISO IEC 14882-2003 Programming languages C++ (Adopted by INCITS)《INCITS采用的C++语言》.pdf_第5页
第5页 / 共786页
亲,该文档总共786页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

1、B CReference numberISO/IEC 14882:2003(E)INTERNATIONALSTANDARDISO/IEC14882Second edition2003-10-15Programming 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/2003Publ

2、ished by American National Standards Institute,25 West 43rd Street, New York, New York 10036Copyright 2003 by Information Technology Industry Council (ITI).All rights reserved.These materials are subject to copyright claims of International Standardization Organization (ISO), InternationalElectrotec

3、hnical 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, withoutthe prior written permission of ITI. All requests perta

4、ining to this standard should be submitted to ITI, 1250 Eye Street NW,Washington, DC 20005.Printed in the United States of AmericaISO/IEC 14882:2003(E) PDF disclaimer This PDF file may contain embedded typefaces. In accordance with Adobes licensing policy, this file may be printed or viewed but shal

5、l not be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In downloading this file, parties accept therein the responsibility of not infringing Adobes licensing policy. The ISO Central Secretariat accepts no liability in this area.

6、Adobe is a trademark of Adobe Systems Incorporated. Details of the software products used to create this PDF file can be found in the General Info relative to the file; the PDF-creation parameters were optimized for printing. Every care has been taken to ensure that the file is suitable for use by I

7、SO member bodies. In the unlikely event that a problem relating to it is found, please inform the Central Secretariat at the address given below. ISO/IEC 2003 All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized in any form or by any means, elect

8、ronic or mechanical, including photocopying and microfilm, without permission in writing from either ISO at the address below or ISOs member body in the country of the requester. ISO copyright office Case postale 56 CH-1211 Geneva 20 Tel. + 41 22 749 01 11 Fax + 41 22 749 09 47 E-mail copyrightiso.o

9、rg Web www.iso.org Published in Switzerland ii ISO/IEC 2003 All rights reservedISO/IEC 14882:2003(E) ISO/IEC 2003 All rights reserved iiiContents1 General 11.1 Scope11.2 Normative references .11.3 Terms and definitions .11.3.1 argument .11.3.2 diagnostic message .21.3.3 dynamic type .21.3.4 ill-form

10、ed program21.3.5 implementation-defined behavior .21.3.6 implementation limits .21.3.7 locale-specific behavior 21.3.8 multibyte character .21.3.9 parameter 21.3.10 signature 21.3.11 static type 21.3.12 undefined behavior .21.3.13 unspecified behavior .31.3.14 well-formed program 31.4 Implementation

11、 compliance.31.5 Structure of this International Standard .41.6 Syntax notation 41.7 The C + + memory model .41.8 The C + + object model 41.9 Program execution .5ISO/IEC 14882:2003(E) iv ISO/IEC 2003 All rights reserved1.10 Acknowledgments .82 Lexical conventions 92.1 Phases of translation 92.2 Char

12、acter sets .102.3 Trigraph sequences 112.4 Preprocessing tokens .112.5 Alternative tokens 122.6 Tokens122.7 Comments 122.8 Header names .132.9 Preprocessing numbers 132.10 Identifiers .132.11 Keywords .142.12 Operators and punctuators .152.13 Literals .152.13.1 Integer literals .152.13.2 Character l

13、iterals .162.13.3 Floating literals .182.13.4 String literals .192.13.5 Boolean literals .193 Basic concepts 213.1 Declarations and definitions 213.2 One definition rule .223.3 Declarative regions and scopes 243.3.1 Point of declaration .253.3.2 Local scope .263.3.3 Function prototype scope 263.3.4

14、Function scope 273.3.5 Namespace scope 273.3.6 Class scope273.3.7 Name hiding283.4 Name lookup 293.4.1 Unqualified name lookup .293.4.2 Argument-dependent name lookup .323.4.3 Qualified name lookup .34ISO/IEC 14882:2003(E) ISO/IEC 2003 All rights reserved v3.4.3.1 Class members .353.4.3.2 Namespace

15、members .353.4.4 Elaborated type specifiers .393.4.5 Class member access 403.4.6 Using-directives and namespace aliases .413.5 Program and linkage 413.6 Start and termination433.6.1 Main function433.6.2 Initialization of non-local objects .443.6.3 Termination.453.7 Storage duration .463.7.1 Static s

16、torage duration 463.7.2 Automatic storage duration.463.7.3 Dynamic storage duration .473.7.3.1 Allocation functions.473.7.3.2 Deallocation functions .483.7.4 Duration of sub-objects.483.8 Object Lifetime 493.9 Types523.9.1 Fundamental types 533.9.2 Compound types .553.9.3 CV-qualifiers 553.10 Lvalue

17、s and rvalues .564 Standard conversions 594.1 Lvalue-to-rvalue conversion 594.2 Array-to-pointer conversion 604.3 Function-to-pointer conversion .604.4 Qualification conversions 604.5 Integral promotions 614.6 Floating point promotion .614.7 Integral conversions .624.8 Floating point conversions .62

18、4.9 Floating-integral conversions 624.10 Pointer conversions 624.11 Pointer to member conversions .63ISO/IEC 14882:2003(E) vi ISO/IEC 2003 All rights reserved4.12 Boolean conversions 635 Expressions .655.1 Primary expressions .665.2 Postfix expressions 685.2.1 Subscripting 685.2.2 Function call .685

19、.2.3 Explicit type conversion (functional notation) .705.2.4 Pseudo destructor call .705.2.5 Class member access 705.2.6 Increment and decrement 715.2.7 Dynamic cast 725.2.8 Type identification 735.2.9 Static cast 745.2.10 Reinterpret cast .755.2.11 Const cast 765.3 Unary expressions 785.3.1 Unary o

20、perators.785.3.2 Increment and decrement 795.3.3 Sizeof 795.3.4 New .805.3.5 Delete 835.4 Explicit type conversion (cast notation) 845.5 Pointer-to-member operators .855.6 Multiplicative operators .855.7 Additive operators .865.8 Shift operators 875.9 Relational operators .875.10 Equality operators

21、885.11 Bitwise AND operator 895.12 Bitwise exclusive OR operator .895.13 Bitwise inclusive OR operator .895.14 Logical AND operator 895.15 Logical OR operator .905.16 Conditional operator 905.17 Assignment operators 91ISO/IEC 14882:2003(E) ISO/IEC 2003 All rights reserved vii5.18 Comma operator 925.

22、19 Constant expressions .926 Statements .956.1 Labeled statement 956.2 Expression statement .956.3 Compound statement or block .956.4 Selection statements.966.4.1 The if statement 976.4.2 The switch statement 976.5 Iteration statements 976.5.1 The while statement .986.5.2 The do statement 986.5.3 Th

23、e for statement996.6 Jump statements .996.6.1 The break statement .996.6.2 The continue statement1006.6.3 The return statement 1006.6.4 The goto statement .1006.7 Declaration statement 1006.8 Ambiguity resolution .1017 Declarations 1037.1 Specifiers .1047.1.1 Storage class specifiers .1057.1.2 Funct

24、ion specifiers 1067.1.3 The typedef specifier1077.1.4 The friend specifier 1087.1.5 Type specifiers 1087.1.5.1 The cv-qualifiers1097.1.5.2 Simple type specifiers 1107.1.5.3 Elaborated type specifiers 1117.2 Enumeration declarations 1127.3 Namespaces .1147.3.1 Namespace definition .1147.3.1.1 Unnamed

25、 namespaces 1157.3.1.2 Namespace member definitions .1157.3.2 Namespace alias 1177.3.3 The using declaration 1177.3.4 Using directive 1237.4 The asm declaration 126ISO/IEC 14882:2003(E) viii ISO/IEC 2003 All rights reserved7.5 Linkage specifications .1268 Declarators 1318.1 Type names 1328.2 Ambigui

26、ty resolution .1328.3 Meaning of declarators 1348.3.1 Pointers .1358.3.2 References .1358.3.3 Pointers to members .1368.3.4 Arrays .1378.3.5 Functions.1388.3.6 Default arguments .1418.4 Function definitions .1448.5 Initializers 1458.5.1 Aggregates 1478.5.2 Character arrays 1508.5.3 References .1509

27、Classes 1539.1 Class names .1539.2 Class members .1559.3 Member functions 1579.3.1 Nonstatic member functions .1589.3.2 The this pointer .1609.4 Static members.1609.4.1 Static member functions .1619.4.2 Static data members 1619.5 Unions 1629.6 Bit-fields 1639.7 Nested class declarations .1649.8 Loca

28、l class declarations .1659.9 Nested type names .16610 Derived classes .16710.1 Multiple base classes .16810.2 Member name lookup 16910.3 Virtual functions 172ISO/IEC 14882:2003(E) ISO/IEC 2003 All rights reserved ix10.4 Abstract classes 17611 Member access control .17911.1 Access specifiers 18011.2

29、Accessibility of base classes and base class members .18111.3 Access declarations 18211.4 Friends .18311.5 Protected member access .18611.6 Access to virtual functions.18711.7 Multiple access 18811.8 Nested classes 18812 Special member functions.18912.1 Constructors .18912.2 Temporary objects .19112

30、.3 Conversions .19212.3.1 Conversion by constructor 19312.3.2 Conversion functions 19412.4 Destructors .19512.5 Free store .19812.6 Initialization .19912.6.1 Explicit initialization 20012.6.2 Initializing bases and members .20112.7 Construction and destruction .20412.8 Copying class objects 20713 Ov

31、erloading 21313.1 Overloadable declarations21313.2 Declaration matching .21513.3 Overload resolution .21613.3.1 Candidate functions and argument lists 21713.3.1.1 Function call syntax .21813.3.1.1.1 Call to named function21813.3.1.1.2 Call to object of class type 21913.3.1.2 Operators in expressions

32、 220ISO/IEC 14882:2003(E) x ISO/IEC 2003 All rights reserved13.3.1.3 Initialization by constructor .22213.3.1.4 Copy-initialization of class by user-defined conversion22213.3.1.5 Initialization by conversion function .22213.3.1.6 Initialization by conversion function for direct reference binding 223

33、13.3.2 Viable functions 22313.3.3 Best Viable Function 22313.3.3.1 Implicit conversion sequences .22513.3.3.1.1 Standard conversion sequences 22713.3.3.1.2 User-defined conversion sequences 22713.3.3.1.3 Ellipsis conversion sequences.22813.3.3.1.4 Reference binding .22813.3.3.2 Ranking implicit conv

34、ersion sequences.22813.4 Address of overloaded function .23013.5 Overloaded operators .23213.5.1 Unary operators.23313.5.2 Binary operators23313.5.3 Assignment .23313.5.4 Function call .23413.5.5 Subscripting 23413.5.6 Class member access 23413.5.7 Increment and decrement 23413.6 Built-in operators

35、.23514 Templates 23914.1 Template parameters 24014.2 Names of template specializations .24214.3 Template arguments.24414.3.1 Template type arguments 24514.3.2 Template non-type arguments 24614.3.3 Template template arguments .24814.4 Type equivalence .24814.5 Template declarations 24914.5.1 Class te

36、mplates .24914.5.1.1 Member functions of class templates.24914.5.1.2 Member classes of class templates 25014.5.1.3 Static data members of class templates25014.5.2 Member templates 25114.5.3 Friends 25214.5.4 Class template partial specializations .25414.5.4.1 Matching of class template partial speci

37、alizations 25614.5.4.2 Partial ordering of class template specializations 25714.5.4.3 Members of class template specializations 25714.5.5 Function templates 25814.5.5.1 Function template overloading 25914.5.5.2 Partial ordering of function templates .260ISO/IEC 14882:2003(E) ISO/IEC 2003 All rights

38、reserved xi14.6 Name resolution .26114.6.1 Locally declared names 26414.6.2 Dependent names 26714.6.2.1 Dependent types.26814.6.2.2 Type-dependent expressions 26814.6.2.3 Value-dependent expressions 26914.6.2.4 Dependent template arguments 26914.6.3 Non-dependent names.27014.6.4 Dependent name resol

39、ution 27014.6.4.1 Point of instantiation 27014.6.4.2 Candidate functions .27114.6.5 Friend names declared within a class template .27114.7 Template instantiation and specialization 27214.7.1 Implicit instantiation .27314.7.2 Explicit instantiation .27614.7.3 Explicit specialization .27714.8 Function

40、 template specializations 28214.8.1 Explicit template argument specification .28314.8.2 Template argument deduction 28514.8.2.1 Deducing template arguments from a function call .28714.8.2.2 Deducing template arguments taking the address of a function template .28814.8.2.3 Deducing conversion functio

41、n template arguments.28814.8.2.4 Deducing template arguments from a type 28814.8.3 Overload resolution 29315 Exception handling .29715.1 Throwing an exception 29815.2 Constructors and destructors30015.3 Handling an exception .30015.4 Exception specifications 30215.5 Special functions 30415.5.1 The t

42、erminate() function 30415.5.2 The unexpected() function 30515.5.3 The uncaught_exception() function .30515.6 Exceptions and access 30516 Preprocessing directives .30716.1 Conditional inclusion .30816.2 Source file inclusion 30916.3 Macro replacement 31016.3.1 Argument substitution 31116.3.2 The # op

43、erator 31116.3.3 The # operator 312ISO/IEC 14882:2003(E) xii ISO/IEC 2003 All rights reserved16.3.4 Rescanning and further replacement.31216.3.5 Scope of macro definitions .31216.4 Line control 31416.5 Error directive 31416.6 Pragma directive 31416.7 Null directive .31416.8 Predefined macro names 31

44、517 Library introduction 31717.1 Definitions .31717.1.1 arbitrary-positional stream 31717.1.2 character 31717.1.3 character container type 31717.1.4 comparison function .31717.1.5 component.31817.1.6 default behavior 31817.1.7 handler function 31817.1.8 iostream class templates .31817.1.9 modifier f

45、unction 31817.1.10 object state 31817.1.11 narrow-oriented iostream classes 31817.1.12 NTCTS 31817.1.13 observer function 31817.1.14 replacement function.31817.1.15 required behavior 31817.1.16 repositional stream 31917.1.17 reserved function.31917.1.18 traits class31917.1.19 wide-oriented iostream

46、classes .31917.2 Additional definitions 31917.3 Method of description (Informative) .31917.3.1 Structure of each subclause.31917.3.1.1 Summary 32017.3.1.2 Requirements .32017.3.1.3 Specifications .32017.3.1.4 C Library 32117.3.2 Other conventions .32117.3.2.1 Type descriptions .32117.3.2.1.1 Enumera

47、ted types32217.3.2.1.2 Bitmask types32217.3.2.1.3 Character sequences 32317.3.2.1.3.1 Byte strings 32317.3.2.1.3.2 Multibyte strings 32417.3.2.1.3.3 Wide-character sequences 32417.3.2.2 Functions within classes 32417.3.2.3 Private members 324ISO/IEC 14882:2003(E) ISO/IEC 2003 All rights reserved xii

48、i17.4 Library-wide requirements 32417.4.1 Library contents and organization 32517.4.1.1 Library contents .32517.4.1.2 Headers 32517.4.1.3 Freestanding implementations .32617.4.2 Using the library .32617.4.2.1 Headers 32617.4.2.2 Linkage 32717.4.3 Constraints on programs .32717.4.3.1 Reserved names .

49、32717.4.3.1.1 Macro names .32717.4.3.1.2 Global names 32717.4.3.1.3 External linkage 32817.4.3.1.4 Types.32817.4.3.2 Headers 32817.4.3.3 Derived classes 32817.4.3.4 Replacement functions.32817.4.3.5 Handler functions.32917.4.3.6 Other functions 32917.4.3.7 Function arguments .33017.4.3.8 Required paragraph 33017.4.4 Conforming implementations .33017.4.4.1 Headers 33017.4.4.2 Restrictions on macro definitions 33017.4.4.3 Global or non-member functions .33017.4.4.4 Member functions 33117.4.4.5 Reentrancy .33117.4.4.6 Protection wit

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 标准规范 > 国际标准 > ANSI

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1