Tài liệu Working with Structures

Thảo luận trong 'Thiết Kế Web' bắt đầu bởi Thúy Viết Bài, 5/12/13.

  1. Thúy Viết Bài

    Thành viên vàng

    Bài viết:
    198,891
    Được thích:
    173
    Điểm thành tích:
    0
    Xu:
    0Xu
    This chapter discusses structures, which are the most complex
    and most useful of the complex data types. You learn what structures
    are, how to use them, and when to use them.
    What is a Structure?
    Simply put, a structure is a container for other variables. Structures
    are like arrays in that they contain programmatically addressable elements,
    but structures name each element rather than simply assigning
    them numeric positions. Graphically, a structure looks as shown
    in Figure 15-1.
    Figure 15-1: A graphical representation of
    a structure.
    Notice that each element in a structure has a name. Always remember
    that each element in an array has a number, while structure elements
    have names. You see how naming each element is useful
    throughout the chapter.
    Creating a Structure
    As are arrays, structures are complex objects with a specific initialization
    function, as the following example shows:
    <cfset myStruct = StructNew()>
    StructNew() doesn’t take any arguments, because structures do not
    have a simple dimension. As you will see in the section “Nested
    Structures” later in this chapter, structures may have arbitrarily complex
    dimensions.
    If myStruct currently contains a value, StructNew()destroys the old
    value and replaces it with an empty structure.
     

    Các file đính kèm:

Đang tải...