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

前端 未结 3 741
爱一瞬间的悲伤
爱一瞬间的悲伤 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 09:13

    Yes. In case of C language, you need to explicitly give the type of the variable otherwise the compiler will throw an error: 'Books' undeclared.(in the above case)

    So you need to use keyword struct if you are using C language but you can skip this if you are writing this in C++.

    Hope this helps.

提交回复
热议问题