THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng | |
---|---|
Số trang | 193 |
Dung lượng | 769,14 KB |
Nội dung
Ngày đăng: 09/08/2014, 12:22
Nguồn tham khảo
Tài liệu tham khảo | Loại | Chi tiết | ||
---|---|---|---|---|
8.3.2 References1 In a declaration T D where D has the form& D1and the type of the identifier in the declaration T D1 is “derived-declarator-type-list T,” then the type of the identifier of D is “derived-declarator-type-list reference to T.” At all times during the determination of a type, any type of the form “cv-qualifier-seq reference to T” is adjusted to be “reference to T”. [Example: intypedef int& A;const A aref = 3;the type of aref is “reference to int ”, not “ const reference to int ”. ] A declarator that specifies the type “reference to cv void” is ill-formed.2 [Example:void f(double& a) { a += 3.14; } // ...double d = 0;f(d);declares a to be a reference parameter of f so the call f(d) will add 3.14 to d . int v[20];// ...int& g(int i) { return v[i]; } // ...g(3) = 7;declares the function g() to return a reference to an integer so g(3)=7 will assign 7 to the fourth element of the array v. For another example,struct link { link* next;};link* first | Sách, tạp chí |
|
||
58) This excludes parameters of type “ptr-arr-seq T2 ” where T2 is “pointer to array of unknown bound of T ” and where ptr-arr-seq means any sequence of “pointer to” and “array of” derived declarator types. This exclusion applies to the parameters of the function, and if a parameter is a pointer to function or pointer to member function then to its parameters also, etc | Sách, tạp chí |
|
||
8.4 Function definitions1 Function definitions have the form function-definition:decl-specifier-seq opt declarator ctor-initializer opt function-body decl-specifier-seq opt declarator function-try-blockfunction-body:compound-statementThe declarator in a function-definition shall have the formD1 ( parameter-declaration-clause ) cv-qualifier-seq opt exception-specification opt as described in 8.3.5. A function shall be defined only in namespace or class scope.2 The parameters are in the scope of the outermost block of the function-body.3 [Example: a simple example of a complete function definition is int max(int a, int b, int c){int m = (a > b) ? a : b;return (m > c) ? m : c;}Here int is the decl-specifier-seq; max(int a, int b, int c) is the declarator; { /* ... */ } is the function-body. ]4 A ctor-initializer is used only in a constructor; see 12.1 and 12.6.5 A cv-qualifier-seq can be part of a non-static member function declaration, non-static member function def- inition, or pointer to member function only; see 9.4.2. It is part of the function type.6 [Note: unused parameters need not be named. For example, void print(int a, int){printf("a = %d\n",a);}—end note] | Sách, tạp chí |
|
||
8.5.2 Character arrays1 A char array (whether plain char, signed, or unsigned) can be initialized by a string; a wchar_t array can be initialized by a wide string literal; successive characters of the string initialize the members of the array. [Example:char msg[] = "Syntax error on line %s\n";shows a character array whose members are initialized with a string. Note that because ’\n’ is a single character and because a trailing ’\0’ is appended, sizeof(msg) is 25 . ] | Sách, tạp chí |
|
||
61) Because the type of the temporary is the same as the type of the object being initialized, this direct-initialization, if well-formed, will use a copy constructor (12.8) to copy the temporary | Khác | |||
64) Clearly, if the reference initialization being processed is one for the first argument of a copy constructor call, an implementation must eventually choose the direct-binding alternative to avoid infinite recursion | Khác |
Xem thêm
TỪ KHÓA LIÊN QUAN
TÀI LIỆU CÙNG NGƯỜI DÙNG
TÀI LIỆU LIÊN QUAN