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

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

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

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

There is no such disambiguation when considering the set of names found as a result of following usingdirectives.123ISO/IEC 14882:1998(E)© ISO/IEC7.5 Linkage specifications7 Declarationslinkage-specification:extern string-literal { declaration-seqopt }extern string-literal declarationThe string-literal indicates the required language linkage. The meaning of the string-literal isimplementation-defined.

A linkage-specification with a string that is unknown to the implementation isill-formed. When the string-literal in a linkage-specification names a programming language, the spellingof the programming language’s name is implementation-defined. [Note: it is recommended that the spelling be taken from the document defining that language, for example Ada (not ADA) and Fortran orFORTRAN (depending on the vintage). The semantics of a language linkage other than C++ or C areimplementation-defined. ]3Every implementation shall provide for linkage to functions written in the C programming language, "C",and linkage to C++ functions, "C++".

[Example:complex sqrt(complex);extern "C" {double sqrt(double);}// C++ linkage by default// C linkage—end example]4Linkage specifications nest. When linkage specifications nest, the innermost one determines the languagelinkage. A linkage specification does not establish a scope. A linkage-specification shall occur only innamespace scope (3.3). In a linkage-specification, the specified language linkage applies to the functiontypes of all function declarators, function names, and variable names introduced by the declaration(s).[Example:extern "C" void f1(void(*pf)(int));// the name f1 and its function type have C language// linkage; pf is a pointer to a C functionextern "C" typedef void FUNC();FUNC f2;// the name f2 has C++ language linkage and the// function’s type has C language linkageextern "C" FUNC f3;// the name of function f3 and the function’s type// have C language linkagevoid (*pf2)(FUNC*);// the name of the variable pf2 has C++ linkage and// the type of pf2 is pointer to C++ function that// takes one parameter of type pointer to C function—end example] A C language linkage is ignored for the names of class members and the member functiontype of class member functions.

[Example:extern "C" typedef void FUNC_c();class C {void mf1(FUNC_c*);// the name of the function mf1 and the member// function’s type have C++ language linkage; the// parameter has type pointer to C functionFUNC_c mf2;// the name of the function mf2 and the member// function’s type have C++ language linkagestatic FUNC_c* q;// the name of the data member q has C++ language// linkage and the data member’s type is pointer to// C function};124© ISO/IECISO/IEC 14882:1998(E)7 Declarations7.5 Linkage specificationsextern "C" {class X {void mf();void mf2(void(*)());// the name of the function mf and the member// function’s type have C++ language linkage// the name of the function mf2 has C++ language// linkage; the parameter has type pointer to// C function};}—end example]5If two declarations of the same function or object specify different linkage-specifications (that is, thelinkage-specifications of these declarations specify different string-literals), the program is ill-formed if thedeclarations appear in the same translation unit, and the one definition rule (3.2) applies if the declarationsappear in different translation units.

Except for functions with C++ linkage, a function declaration withouta linkage specification shall not precede the first linkage specification for that function. A function can bedeclared without a linkage specification after an explicit linkage specification has been seen; the linkageexplicitly specified in the earlier declaration is not affected by such a function declaration.6At most one function with a particular name can have C language linkage. Two declarations for a functionwith C language linkage with the same function name (ignoring the namespace names that qualify it) thatappear in different namespace scopes refer to the same function.

Two declarations for an object with C language linkage with the same name (ignoring the namespace names that qualify it) that appear in differentnamespace scopes refer to the same object. [Note: because of the one definition rule (3.2), only one definition for a function or object with C linkage may appear in the program; that is, such a function or objectmust not be defined in more than one namespace scope. For example,namespace A {extern "C" int f();extern "C" int g() { return 1; }extern "C" int h();}namespace B {extern "C" int f();extern "C" int g() { return 1; }// A::f and B::f refer// to the same function// ill-formed, the function g// with C language linkage// has two definitions}// definition for the function f// with C language linkageint A::f() { return 98; }extern "C" int h() { return 97; }// definition for the function h// with C language linkage// A::h and ::h refer to the same function—end note]7Except for functions with internal linkage, a function first declared in a linkage-specification behaves as afunction with external linkage.

[Example:extern "C" double f();static double f();// erroris ill-formed (7.1.1). ] The form of linkage-specification that contains a braced-enclosed declaration-seqdoes not affect whether the contained declarations are definitions or not (3.1); the form of linkagespecification directly containing a single declaration is treated as an extern specifier (7.1.1) for the purpose of determining whether the contained declaration is a definition. [Example:125ISO/IEC 14882:1998(E)© ISO/IEC7.5 Linkage specificationsextern "C" int i;extern "C" {int i;}7 Declarations// declaration// definition—end example] A linkage-specification directly containing a single declaration shall not specify a storageclass.

[Example:extern "C" static void f();// error—end example]8[Note: because the language linkage is part of a function type, when a pointer to C function (for example) isdereferenced, the function to which it refers is considered a C function. ]9Linkage from C++ to objects defined in other languages and to objects defined in C++ from other languagesis implementation-defined and language-dependent. Only where the object layout strategies of two language implementations are similar enough can such linkage be achieved.126© ISO/IECISO/IEC 14882:1998(E)8 Declarators1[dcl.decl]A declarator declares a single object, function, or type, within a declaration.

The init-declarator-listappearing in a declaration is a comma-separated sequence of declarators, each of which can have an initializer.init-declarator-list:init-declaratorinit-declarator-list , init-declaratorinit-declarator:declarator initializeropt2The two components of a declaration are the specifiers (decl-specifier-seq; 7.1) and the declarators (initdeclarator-list). The specifiers indicate the type, storage class or other properties of the objects, functionsor typedefs being declared. The declarators specify the names of these objects, functions or typedefs, and(optionally) modify the type of the specifiers with operators such as * (pointer to) and () (function returning).

Initial values can also be specified in a declarator; initializers are discussed in 8.5 and 12.6.3Each init-declarator in a declaration is analyzed separately as if it was in a declaration by itself.85)4Declarators have the syntaxdeclarator:direct-declaratorptr-operator declaratordirect-declarator:declarator-iddirect-declarator ( parameter-declaration-clause ) cv-qualifier-seqopt exception-specificationoptdirect-declarator [ constant-expressionopt ]( declarator )ptr-operator:* cv-qualifier-seqopt&::opt nested-name-specifier * cv-qualifier-seqopt__________________85) A declaration with several declarators is usually equivalent to the corresponding sequence of declarations each with a singledeclarator. That isTD1, D2, ...

Dn;is usually equvalent toTD1; T D2; ... T Dn;where T is a decl-specifier-seq and each Di is a init-declarator. The exception occurs when a name introduced by one of thedeclarators hides a type name used by the dcl-specifiers, so that when the same dcl-specifiers are used in a subsequent declaration,they do not have the same meaning, as instruct S { ... };SS, T;// declare two instances of struct Swhich is not equivalent tostruct S { ...

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

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

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

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