Главная » Просмотр файлов » Стандарт C++ 98

Стандарт C++ 98 (1119566), страница 33

Файл №1119566 Стандарт C++ 98 (Стандарт C++ 98) 33 страницаСтандарт C++ 98 (1119566) страница 332019-05-09СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 33)

If,during parsing, a name in a template parameter is bound differently than it would be bound during a trialparse, the program is ill-formed. No diagnostic is required. [Note: This can occur only when the name isdeclared earlier in the declaration. ] [Example:struct T1 {T1 operator()(int x) { return T1(x); }int operator=(int x) { return x; }T1(int) { }};struct T2 { T2(int){ } };int a, (*(*b)(T2))(int), c, d;void f() {// disambiguation requires this to be parsed// as a declarationT1(a) = 3,T2(4),// T2 will be declared as(*(*b)(T2(c)))(int(d)); // a variable of type T1// but this will not allow// the last part of the// declaration to parse// properly since it depends// on T2 being a type-name}—end example]100© ISO/IECISO/IEC 14882:1998(E)7 Declarations1[dcl.dcl]Declarations specify how names are to be interpreted.

Declarations have the formdeclaration-seq:declarationdeclaration-seq declarationdeclaration:block-declarationfunction-definitiontemplate-declarationexplicit-instantiationexplicit-specializationlinkage-specificationnamespace-definitionblock-declaration:simple-declarationasm-definitionnamespace-alias-definitionusing-declarationusing-directivesimple-declaration:decl-specifier-seqopt init-declarator-listopt ;[Note: asm-definitions are described in 7.4, and linkage-specifications are described in 7.5. Functiondefinitions are described in 8.4 and template-declarations are described in clause 14.

Namespacedefinitions are described in 7.3.1, using-declarations are described in 7.3.3 and using-directives aredescribed in 7.3.4. ] The simple-declarationdecl-specifier-seqopt init-declarator-listopt ;is divided into two parts: decl-specifiers, the components of a decl-specifier-seq, are described in 7.1 anddeclarators, the components of an init-declarator-list, are described in clause 8.2A declaration occurs in a scope (3.3); the scope rules are summarized in 3.4. A declaration that declares afunction or defines a class, namespace, template, or function also has one or more scopes nested within it.These nested scopes, in turn, can have declarations nested within them. Unless otherwise stated, utterancesin clause 7 about components in, of, or contained by a declaration or subcomponent thereof refer only tothose components of the declaration that are not nested within scopes nested within the declaration.3In a simple-declaration, the optional init-declarator-list can be omitted only when declaring a class (clause9) or enumeration (7.2), that is, when the decl-specifier-seq contains either a class-specifier, an elaboratedtype-specifier with a class-key (9.1), or an enum-specifier.

In these cases and whenever a class-specifier orenum-specifier is present in the decl-specifier-seq, the identifiers in these specifiers are among the namesbeing declared by the declaration (as class-names, enum-names, or enumerators, depending on the syntax).In such cases, and except for the declaration of an unnamed bit-field (9.6), the decl-specifier-seq shall introduce one or more names into the program, or shall redeclare a name introduced by a previous declaration.[Example:enum { };typedef class { };// ill-formed// ill-formed—end example]101ISO/IEC 14882:1998(E)© ISO/IEC7 Declarations7 Declarations4Each init-declarator in the init-declarator-list contains exactly one declarator-id, which is the namedeclared by that init-declarator and hence one of the names declared by the declaration.

The type-specifiers(7.1.5) in the decl-specifier-seq and the recursive declarator structure of the init-declarator describe a type(8.3), which is then associated with the name being declared by the init-declarator.5If the decl-specifier-seq contains the typedef specifier, the declaration is called a typedef declaration andthe name of each init-declarator is declared to be a typedef-name, synonymous with its associated type(7.1.3). If the decl-specifier-seq contains no typedef specifier, the declaration is called a functiondeclaration if the type associated with the name is a function type (8.3.5) and an object declaration otherwise.6Syntactic components beyond those found in the general form of declaration are added to a function declaration to make a function-definition.

An object declaration, however, is also a definition unless it containsthe extern specifier and has no initializer (3.1). A definition causes the appropriate amount of storage tobe reserved and any appropriate initialization (8.5) to be done.7Only in function declarations for constructors, destructors, and type conversions can the decl-specifier-seqbe omitted.78)7.1 Specifiers1[dcl.spec]The specifiers that can be used in a declaration aredecl-specifier:storage-class-specifiertype-specifierfunction-specifierfriendtypedefdecl-specifier-seq:decl-specifier-seqopt decl-specifier2The longest sequence of decl-specifiers that could possibly be a type name is taken as the decl-specifier-seqof a declaration.

The sequence shall be self-consistent as described below. [Example:typedef char* Pc;static Pc;// error: name missingHere, the declaration static Pc is ill-formed because no name was specified for the static variable oftype Pc. To get a variable called Pc, a type-specifier (other than const or volatile) has to be presentto indicate that the typedef-name Pc is the name being (re)declared, rather than being part of the declspecifier sequence. For another example,void f(const Pc);void g(const int Pc);// void f(char* const) (not const char*)// void g(const int)—end example]3[Note: since signed, unsigned, long, and short by default imply int, a type-name appearing afterone of those specifiers is treated as the name being (re)declared.

[Example:void h(unsigned Pc);void k(unsigned int Pc);—end example] —end note]__________________78) The “implicit int” rule of C is no longer supported.102// void h(unsigned int)// void k(unsigned int)© ISO/IECISO/IEC 14882:1998(E)7 Declarations7.1 Specifiers7.1.1 Storage class specifiers1[dcl.stc]The storage class specifiers arestorage-class-specifier:autoregisterstaticexternmutableAt most one storage-class-specifier shall appear in a given decl-specifier-seq.

If a storage-class-specifierappears in a decl-specifier-seq, there can be no typedef specifier in the same decl-specifier-seq and theinit-declarator-list of the declaration shall not be empty (except for global anonymous unions, which shallbe declared static (9.5)). The storage-class-specifier applies to the name declared by each initdeclarator in the list and not to any names declared by other specifiers. A storage-class-specifier shall notbe specified in an explicit specialization (14.7.3) or an explicit instantiation (14.7.2) directive.2The auto or register specifiers can be applied only to names of objects declared in a block (6.3) or tofunction parameters (8.4). They specify that the named object has automatic storage duration (3.7.2).

Anobject declared without a storage-class-specifier at block scope or declared as a function parameter hasautomatic storage duration by default. [Note: hence, the auto specifier is almost always redundant and notoften used; one use of auto is to distinguish a declaration-statement from an expression-statement (6.8)explicitly. —end note]3A register specifier has the same semantics as an auto specifier together with a hint to the implementation that the object so declared will be heavily used. [Note: the hint can be ignored and in most implementations it will be ignored if the address of the object is taken.

—end note]4The static specifier can be applied only to names of objects and functions and to anonymous unions(9.5). There can be no static function declarations within a block, nor any static function parameters. A static specifier used in the declaration of an object declares the object to have static storageduration (3.7.1). A static specifier can be used in declarations of class members; 9.4 describes its effect.For the linkage of a name declared with a static specifier, see 3.5.5The extern specifier can be applied only to the names of objects and functions.

The extern specifiercannot be used in the declaration of class members or function parameters. For the linkage of a namedeclared with an extern specifier, see 3.5.6A name declared in a namespace scope without a storage-class-specifier has external linkage unless it hasinternal linkage because of a previous declaration and provided it is not declared const.

Objects declaredconst and not explicitly declared extern have internal linkage.7The linkages implied by successive declarations for a given entity shall agree. That is, within a givenscope, each declaration declaring the same object name or the same overloading of a function name shallimply the same linkage. Each function in a given set of overloaded functions can have a different linkage,however. [Example:static char* f();char* f(){ /* ... */ }// f() has internal linkage// f() still has internal linkagechar* g();static char* g(){ /* ... */ }// g() has external linkage// error: inconsistent linkagevoid h();inline void h();// external linkageinline void l();void l();// external linkage103ISO/IEC 14882:1998(E)© ISO/IEC7.1.1 Storage class specifiers7 Declarationsinline void m();extern void m();// external linkagestatic void n();inline void n();// internal linkagestatic int a;int a;// a has internal linkage// error: two definitionsstatic int b;extern int b;// b has internal linkage// b still has internal linkageint c;static int c;// c has external linkage// error: inconsistent linkageextern int d;static int d;// d has external linkage// error: inconsistent linkage—end example]8The name of a declared but undefined class can be used in an extern declaration.

Such a declaration canonly be used in ways that do not require a complete class type. [Example:structexternexternexternS;S a;S f();void g(S);void h(){g(a);f();}// error: S is incomplete// error: S is incomplete—end example] The mutable specifier can be applied only to names of class data members (9.2) andcannot be applied to names declared const or static, and cannot be applied to reference members.[Example:class X {mutable const int* p;mutable int* const q;};// OK// ill-formed—end example]9The mutable specifier on a class data member nullifies a const specifier applied to the containing classobject and permits modification of the mutable class member even though the rest of the object is const(7.1.5.1).7.1.2 Function specifiers1[dcl.fct.spec]Function-specifiers can be used only in function declarations.function-specifier:inlinevirtualexplicit2A function declaration (8.3.5, 9.3, 11.4) with an inline specifier declares an inline function.

Характеристики

Тип файла
PDF-файл
Размер
2,05 Mb
Материал
Тип материала
Высшее учебное заведение

Список файлов учебной работы

Свежие статьи
Популярно сейчас
Как Вы думаете, сколько людей до Вас делали точно такое же задание? 99% студентов выполняют точно такие же задания, как и их предшественники год назад. Найдите нужный учебный материал на СтудИзбе!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6418
Авторов
на СтудИзбе
307
Средний доход
с одного платного файла
Обучение Подробнее