tailieunhanh - ansi C reference phần 2

Chức năng thành viên và các dữ liệu tĩnh thành viên của một lớp lồng nhau có thể được định nghĩa trong một phạm vi không gian tên kèm theo định nghĩa của lớp học của họ. [Ví dụ:kèm theo lớp {công cộng: lớp bên trong {static int x; trống f (int i);};}; int kèm theo:: bên trong:: x = 1, khoảng trống kèm theo:: bên trong | Nested class declarations DRAFT 28 April 1995 Classes 9-13 3 Member functions and static data members of a nested class can be defined in a namespace scope enclosing the definition of their class. Example class enclose public class inner static int x void f int i int enclose inner x 1 void enclose inner f int i . end example If class X is defined in a namespace scope a nested class Y may be declared in class X and later defined in the definition of class X or be later defined in a namespace scope enclosing the definition of class X. Example class E class I1 forward declaration of nested class class I2 class I1 definition of nested class class E I2 definition of nested class end example 4 Like a member function a friend function defined within a nested class is in the lexical scope of that class it obeys the same rules for name binding as a static member function of that class and has no special access rights to members of an enclosing class. Local class declarations 1 A class can be defined within a function definition such a class is called a local class. The name of a local class is local to its enclosing scope. The local class is in the scope of the enclosing scope. Declarations in a local class can use only type names static variables extern variables and functions and enumerators from the enclosing scope. Example int x void f static int s int x extern int g struct local int g return x error x is auto int h return s ok int k return x ok int l return g ok . local p 0 error local not in scope end example 2 An enclosing function has no special access to members of the local class it obeys the usual access rules 11 . Member functions of a local class shall be defined within their class definition if they are defined at all. 9-14 Classes DRAFT 28 April 1995 Local class declarations 3 If class X is a local class a nested class Y may be declared in class X and later defined in the definition of class X or be later defined in the same .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.