Is it optional to use struct keyword before declaring a structure object?

前端 未结 3 740
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 08:40

To declare a class object we need the format

classname objectname;

Is it the sameway to declare a structure object?

like



        
3条回答
  •  盖世英雄少女心
    2020-12-10 08:55

    You have to typedef them to make objects without struct keyword

    example:

    typedef struct Books {
         char Title[40];
         char Auth[50];
         char Subj[100];
         int Book_Id;
    } Book;
    

    Then you can define an object without the struct keyword like:

    Book thisBook;
    

提交回复
热议问题