tailieunhanh - Tin học cơ sở 3

2nd aggregate data type: struct. Recall: aggregate meaning "grouping". Recall array: collection of values of same type. Structure: collection of values of different types. Treated as a single item, like arrays. Major difference: Must first "define" struct. Prior to declaring any variables. | Tin học cơ sở 3 Structure Outline Structured Data types Structures as function arguments Self-referential types: linked list Lê Nguyên Khôi Structure 2nd aggregate data type: struct Recall: aggregate meaning "grouping" Recall array: collection of values of same type Structure: collection of values of different types Treated as a single item, like arrays Major difference: Must first "define" struct Prior to declaring any variables Lê Nguyên Khôi Structure Many structured collections of data are: Heterogeneous (components are different types) Fixed-size (well-defined set of components) For example: Student Record Name Nguyen Van A Student Id 1234567 Course INT1005 Date of Birth 01/01/1993 Gender Male Lê Nguyên Khôi Structured Data Types A structure is a collection of variables, perhaps of different types, grouped together under a single name. Structures: Help to organize complicated data into manageable entities. Expose the connection between data within an entity Are defined using the struct keyword. Sometimes referred as records. Lê Nguyên Khôi Structured Data Types Define struct globally (typically) No memory is allocated Just a “placeholder” for what struct will “look like” To define struct, we must give: Name of struct Name of each field Type of each field (could be another record/struct) Lê Nguyên Khôi Defining Struct Defining a new data type using struct struct date name of new "type" { int day; member names int month; int year; }; “;” after “}” struct date yesterday; Once defined, this new data type could be used as other data types: Variable of this type could be assigned to another variable of the same type Variable of this type could be passed as a parameter to a function Lê Nguyên Khôi Declare Structure Variable With structure type defined, now declare variables of this new type: struct date today; Just like declaring simple types Variable today now of type struct date It contains "member values" Each of the struct . | Tin học cơ sở 3 Structure Outline Structured Data types Structures as function arguments Self-referential types: linked list Lê Nguyên Khôi Structure 2nd aggregate data type: struct Recall: aggregate meaning "grouping" Recall array: collection of values of same type Structure: collection of values of different types Treated as a single item, like arrays Major difference: Must first "define" struct Prior to declaring any variables Lê Nguyên Khôi Structure Many structured collections of data are: Heterogeneous (components are different types) Fixed-size (well-defined set of components) For example: Student Record Name Nguyen Van A Student Id 1234567 Course INT1005 Date of Birth 01/01/1993 Gender Male Lê Nguyên Khôi Structured Data Types A structure is a collection of variables, perhaps of different types, grouped together under a single name. Structures: Help to organize complicated data into manageable entities. Expose the connection between data within an entity Are .

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.