Стандарт C++ 98, страница 9

PDF-файл Стандарт C++ 98, страница 9 Практикум (Прикладное программное обеспечение и системы программирования) (37588): Другое - 4 семестрСтандарт C++ 98: Практикум (Прикладное программное обеспечение и системы программирования) - PDF, страница 9 (37588) - СтудИзба2019-05-09СтудИзба

Описание файла

PDF-файл из архива "Стандарт C++ 98", который расположен в категории "". Всё это находится в предмете "практикум (прикладное программное обеспечение и системы программирования)" из 4 семестр, которые можно найти в файловом архиве МГУ им. Ломоносова. Не смотря на прямую связь этого архива с МГУ им. Ломоносова, его также можно найти и в других разделах. .

Просмотр PDF-файла онлайн

Текст 9 страницы из PDF

[Example:// translation unit 1:struct X {X(int);X(int, int);};X::X(int = 0) { }class D: public X { };D d2;// translation unit 2:struct X {X(int);X(int, int);};X::X(int = 0, int = 0) { }class D: public X { };// X(int) called by D()// X(int, int) called by D();// D()’s implicit definition// violates the ODR—end example] If D is a template, and is defined in more than one translation unit, then the last fourrequirements from the list above shall apply to names from the template’s enclosing scope used in thetemplate definition (14.6.3), and also to dependent names at the point of instantiation (14.6.2). If thedefinitions of D satisfy all these requirements, then the program shall behave as if there were a singledefinition of D.

If the definitions of D do not satisfy these requirements, then the behavior is undefined.3.3 Declarative regions and scopes1[basic.scope]Every name is introduced in some portion of program text called a declarative region, which is the largestpart of the program in which that name is valid, that is, in which that name may be used as an unqualifiedname to refer to the same entity. In general, each particular name is valid only within some possibly discontiguous portion of program text called its scope. To determine the scope of a declaration, it is sometimes convenient to refer to the potential scope of a declaration. The scope of a declaration is the same asits potential scope unless the potential scope contains another declaration of the same name. In that case,the potential scope of the declaration in the inner (contained) declarative region is excluded from the scopeof the declaration in the outer (containing) declarative region.__________________25) 8.3.6 describes how default argument names are looked up.24© ISO/IEC3 Basic concepts2ISO/IEC 14882:1998(E)3.3 Declarative regions and scopes[Example: inint j = 24;int main(){int i = j, j;j = 42;}the identifier j is declared twice as a name (and used twice).

The declarative region of the first j includesthe entire example. The potential scope of the first j begins immediately after that j and extends to the endof the program, but its (actual) scope excludes the text between the , and the }. The declarative region ofthe second declaration of j (the j immediately before the semicolon) includes all the text between { and },but its potential scope excludes the declaration of i. The scope of the second declaration of j is the sameas its potential scope. ]3The names declared by a declaration are introduced into the scope in which the declaration occurs, exceptthat the presence of a friend specifier (11.4), certain uses of the elaborated-type-specifier (3.3.1), andusing-directives (7.3.4) alter this general behavior.4Given a set of declarations in a single declarative region, each of which specifies the same unqualifiedname,— they shall all refer to the same entity, or all refer to functions and function templates; or— exactly one declaration shall declare a class name or enumeration name that is not a typedef name andthe other declarations shall all refer to the same object or enumerator, or all refer to functions and function templates; in this case the class name or enumeration name is hidden (3.3.7).

[Note: a namespacename or a class template name must be unique in its declarative region (7.3.2, clause 14). ][Note: these restrictions apply to the declarative region into which a name is introduced, which is not necessarily the same as the region in which the declaration occurs. In particular, elaborated-type-specifiers(3.3.1) and friend declarations (11.4) may introduce a (possibly not visible) name into an enclosing namespace; these restrictions apply to that region. Local extern declarations (3.5) may introduce a name into thedeclarative region where the declaration appears and also introduce a (possibly not visible) name into anenclosing namespace; these restrictions apply to both regions. ]5[Note: the name lookup rules are summarized in 3.4. ]3.3.1 Point of declaration1[basic.scope.pdecl]The point of declaration for a name is immediately after its complete declarator (clause 8) and before itsinitializer (if any), except as noted below. [Example:int x = 12;{ int x = x; }Here the second x is initialized with its own (indeterminate) value.

]2[Note: a nonlocal name remains visible up to the point of declaration of the local name that hides it.[Example:const int i = 2;{ int i[i]; }declares a local array of two integers. ] ]3The point of declaration for an enumerator is immediately after its enumerator-definition. [Example:const int x = 12;{ enum { x = x }; }Here, the enumerator x is initialized with the value of the constant x, namely 12.

]25ISO/IEC 14882:1998(E)© ISO/IEC3.3.1 Point of declaration43 Basic conceptsAfter the point of declaration of a class member, the member name can be looked up in the scope of itsclass. [Note: this is true even if the class is an incomplete class. For example,struct X {enum E { z = 16 };int b[X::z];};// OK—end note]5The point of declaration of a class first declared in an elaborated-type-specifier is as follows:— for an elaborated-type-specifier of the formclass-key identifier ;the elaborated-type-specifier declares the identifier to be a class-name in the scope that contains thedeclaration, otherwise— for an elaborated-type-specifier of the formclass-key identifierif the elaborated-type-specifier is used in the decl-specifier-seq or parameter-declaration-clause of afunction defined in namespace scope, the identifier is declared as a class-name in the namespace thatcontains the declaration; otherwise, except as a friend declaration, the identifier is declared in the smallest non-class, non-function-prototype scope that contains the declaration.

[Note: if the elaboratedtype-specifier designates an enumeration, the identifier must refer to an already declared enum-name. Ifthe identifier in the elaborated-type-specifier is a qualified-id, it must refer to an already declaredclass-name or enum-name. See 3.4.4. ]6[Note: friend declarations refer to functions or classes that are members of the nearest enclosing namespace,but they do not introduce new names into that namespace (7.3.1.2). Function declarations at block scopeand object declarations with the extern specifier at block scope refer to delarations that are members ofan enclosing namespace, but they do not introduce new names into that scope.

]7[Note: For point of instantiation of a template, see 14.7.1. ]3.3.2 Local scope[basic.scope.local]1A name declared in a block (6.3) is local to that block. Its potential scope begins at its point of declaration(3.3.1) and ends at the end of its declarative region.2The potential scope of a function parameter name in a function definition (8.4) begins at its point of declaration. If the function has a function try-block the potential scope of a parameter ends at the end of the lastassociated handler, else it ends at the end of the outermost block of the function definition. A parametername shall not be redeclared in the outermost block of the function definition nor in the outermost block ofany handler associated with a function try-block .3The name in a catch exception-declaration is local to the handler and shall not be redeclared in the outermost block of the handler.4Names declared in the for-init-statement, and in the condition of if, while, for, and switch statementsare local to the if, while, for, or switch statement (including the controlled statement), and shall notbe redeclared in a subsequent condition of that statement nor in the outermost block (or, for the if statement, any of the outermost blocks) of the controlled statement; see 6.4.3.3.3 Function prototype scope1[basic.scope.proto]In a function declaration, or in any function declarator except the declarator of a function definition (8.4),names of parameters (if supplied) have function prototype scope, which terminates at the end of the nearestenclosing function declarator.26© ISO/IECISO/IEC 14882:1998(E)3 Basic concepts3.3.4 Function scope3.3.4 Function scope1[basic.funscope]Labels (6.1) have function scope and may be used anywhere in the function in which they are declared.Only labels have function scope.3.3.5 Namespace scope1[basic.scope.namespace]The declarative region of a namespace-definition is its namespace-body.

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