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

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

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

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

The mechanismsfor starting and terminating a program are discussed. Finally, this clause presents the fundamental types ofthe language and lists the ways of constructing compound types from these.2This clause does not cover concepts that affect only a single part of the language. Such concepts are discussed in the relevant clauses. ]3An entity is a value, object, subobject, base class subobject, array element, variable, function, instance of afunction, enumerator, type, class member, template, or namespace.4A name is a use of an identifier (2.10) that denotes an entity or label (6.6.4, 6.1). A variable is introducedby the declaration of an object.

The variable’s name denotes the object.5Every name that denotes an entity is introduced by a declaration. Every name that denotes a label is introduced either by a goto statement (6.6.4) or a labeled-statement (6.1).6Some names denote types, classes, enumerations, or templates.

In general, it is necessary to determinewhether or not a name denotes one of these entities before parsing the program that contains it. The processthat determines this is called name lookup (3.4).7Two names are the same if— they are identifiers composed of the same character sequence; or— they are the names of overloaded operator functions formed with the same operator; or— they are the names of user-defined conversion functions formed with the same type.8An identifier used in more than one translation unit can potentially refer to the same entity in these translation units depending on the linkage (3.5) of the identifier specified in each translation unit.3.1 Declarations and definitions[basic.def]1A declaration (clause 7) introduces names into a translation unit or redeclares names introduced by previousdeclarations. A declaration specifies the interpretation and attributes of these names.2A declaration is a definition unless it declares a function without specifying the function’s body (8.4), itcontains the extern specifier (7.1.1) or a linkage-specification24) (7.5) and neither an initializer nor afunction-body, it declares a static data member in a class declaration (9.4), it is a class name declaration(9.1), or it is a typedef declaration (7.1.3), a using-declaration (7.3.3), or a using-directive (7.3.4).__________________24) Appearing inside the braced-enclosed declaration-seq in a linkage-specification does not affect whether a declaration is a definition.21ISO/IEC 14882:1998(E)© ISO/IEC3.1 Declarations and definitions33 Basic concepts[Example: all but one of the following are definitions:int a;extern const int c = 1;int f(int x) { return x+a; }struct S { int a; int b; };struct X {int x;static int y;X(): x(0) { }};int X::y = 1;enum { up, down };namespace N { int d; }namespace N1 = N;X anX;// defines a// defines c// defines f and defines x// defines S, S::a, and S::b// defines X// defines nonstatic data member x// declares static data member y// defines a constructor of X// defines X::y// defines up and down// defines N and N::d// defines N1// defines anXwhereas these are just declarations:extern int a;extern const int c;int f(int);struct S;typedef int Int;extern X anotherX;using N::d;// declares a// declares c// declares f// declares S// declares Int// declares anotherX// declares N::d—end example]4[Note: in some circumstances, C++ implementations implicitly define the default constructor (12.1), copyconstructor (12.8), assignment operator (12.8), or destructor (12.4) member functions.

[Example: givenstruct C {string s;};// string is the standard library class (clause 21)int main(){C a;C b = a;b = a;}the implementation will implicitly define functions to make the definition of C equivalent tostruct C {string s;C(): s() { }C(const C& x): s(x.s) { }C& operator=(const C& x) { s = x.s; return *this; }~C() { }};—end example] —end note]5[Note: a class name can also be implicitly declared by an elaborated-type-specifier (3.3.1). ]6A program is ill-formed if the definition of any object gives the object an incomplete type (3.9).3.2 One definition rule1[basic.def.odr]No translation unit shall contain more than one definition of any variable, function, class type, enumerationtype or template.22© ISO/IECISO/IEC 14882:1998(E)3 Basic concepts3.2 One definition rule2An expression is potentially evaluated unless either it is the operand of the sizeof operator (5.3.3), or it isthe operand of the typeid operator and does not designate an lvalue of polymorphic class type (5.2.8).An object or non-overloaded function is used if its name appears in a potentially-evaluated expression.

Avirtual member function is used if it is not pure. An overloaded function is used if it is selected by overloadresolution when referred to from a potentially-evaluated expression. [Note: this covers calls to named functions (5.2.2), operator overloading (clause 13), user-defined conversions (12.3.2), allocation function forplacement new (5.3.4), as well as non-default initialization (8.5). A copy constructor is used even if the callis actually elided by the implementation.

] An allocation or deallocation function for a class is used by anew expression appearing in a potentially-evaluated expression as specified in 5.3.4 and 12.5. A deallocation function for a class is used by a delete expression appearing in a potentially-evaluated expression asspecified in 5.3.5 and 12.5. A copy-assignment function for a class is used by an implicitly-defined copyassignment function for another class as specified in 12.8. A default constructor for a class is used bydefault initialization as specified in 8.5. A constructor for a class is used as specified in 8.5. A destructorfor a class is used as specified in 12.4.3Every program shall contain exactly one definition of every non-inline function or object that is used in thatprogram; no diagnostic required.

The definition can appear explicitly in the program, it can be found in thestandard or a user-defined library, or (when appropriate) it is implicitly defined (see 12.1, 12.4 and 12.8).An inline function shall be defined in every translation unit in which it is used.4Exactly one definition of a class is required in a translation unit if the class is used in a way that requires theclass type to be complete.

[Example: the following complete translation unit is well-formed, even though itnever defines X:struct X;struct X* x1;X* x2;// declare X as a struct type// use X in pointer formation// use X in pointer formation—end example] [Note: the rules for declarations and expressions describe in which contexts complete classtypes are required.

A class type T must be complete if:— an object of type T is defined (3.1, 5.3.4), or— an lvalue-to-rvalue conversion is applied to an lvalue referring to an object of type T (4.1), or— an expression is converted (either implicitly or explicitly) to type T (clause 4, 5.2.3, 5.2.7, 5.2.9, 5.4), or— an expression that is not a null pointer constant, and has type other than void *, is converted to thetype pointer to T or reference to T using an implicit conversion (clause 4), a dynamic_cast (5.2.7) ora static_cast (5.2.9), or— a class member access operator is applied to an expression of type T (5.2.5), or— the typeid operator (5.2.8) or the sizeof operator (5.3.3) is applied to an operand of type T, or— a function with a return type or argument type of type T is defined (3.1) or called (5.2.2), or— an lvalue of type T is assigned to (5.17).

]5There can be more than one definition of a class type (clause 9), enumeration type (7.2), inline functionwith external linkage (7.1.2), class template (clause 14), non-static function template (14.5.5), static datamember of a class template (14.5.1.3), member function template (14.5.1.1), or template specialization forwhich some template parameters are not specified (14.7, 14.5.4) in a program provided that each definitionappears in a different translation unit, and provided the definitions satisfy the following requirements.Given such an entity named D defined in more than one translation unit, then— each definition of D shall consist of the same sequence of tokens; and— in each definition of D, corresponding names, looked up according to 3.4, shall refer to an entity definedwithin the definition of D, or shall refer to the same entity, after overload resolution (13.3) and aftermatching of partial template specialization (14.8.3), except that a name can refer to a const objectwith internal or no linkage if the object has the same integral or enumeration type in all definitions of D,23ISO/IEC 14882:1998(E)© ISO/IEC3.2 One definition rule3 Basic conceptsand the object is initialized with a constant expression (5.19), and the value (but not the address) of theobject is used, and the object has the same value in all definitions of D; and— in each definition of D, the overloaded operators referred to, the implicit calls to conversion functions,constructors, operator new functions and operator delete functions, shall refer to the same function, or toa function defined within the definition of D; and— in each definition of D, a default argument used by an (implicit or explicit) function call is treated as ifits token sequence were present in the definition of D; that is, the default argument is subject to the threerequirements described above (and, if the default argument has sub-expressions with default arguments,this requirement applies recursively).25)— if D is a class with an implicitly-declared constructor (12.1), it is as if the constructor was implicitlydefined in every translation unit where it is used, and the implicit definition in every translation unitshall call the same constructor for a base class or a class member of D.

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

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

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

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