在声明结构对象之前是否可以选择使用 struct 关键字? [英] Is it optional to use struct keyword before declaring a structure object?

查看:43
本文介绍了在声明结构对象之前是否可以选择使用 struct 关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要声明一个类对象,我们需要格式

To declare a class object we need the format

classname objectname;

声明结构对象也是一样的吗?

Is it the sameway to declare a structure object?

喜欢

structname objectname;

我在此处找到了一个声明为

struct Books Book1;

其中 Books 是结构名称,Book1 是其对象名称.那么在声明结构对象之前是否需要使用关键字struct?

where Books is the structure name and Book1 is its object name. So is there any need of usinge the keyword struct before declaring a structure object?

推荐答案

你必须 typedef 它们来制作没有 struct 关键字的对象

You have to typedef them to make objects without struct keyword

示例:

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

然后你可以定义一个没有 struct 关键字的对象,例如:

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

Book thisBook;

这篇关于在声明结构对象之前是否可以选择使用 struct 关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆