C + + data structures

Source: Internet
Author: User

Defining structures

In order to define the structure, you must use a struct statement. A struct statement defines a new data type that contains multiple members, with the format of the struct statement as follows:

struct type_name { member_type1 member_name1; < Span class= "Hl-code" > member_type2 member_name2; < Span class= "Hl-code" > member_type3 member_ Name3 . . } object_names; typedef keyword

The following is a simpler way to define the structure, and you can take an "alias" for the type you create. For example:

typedef struct< Span class= "PLN" >{ char title [50]; char Author[50]; char Subject[100  int Book_id;}books;          

You can now use Books directly to define variables of type Books , without using the struct keyword. Here is an example:

BooksBook1,Book2;   

C + + data structures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.