Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Why not declare a class or enumerated value in a statement in C++ and define a variable of that type at the same time

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains why C++ should not declare a class or enumerated value in a sentence and define the type of variable at the same time. The content in the article is simple and clear, and it is easy to learn and understand. Next, please follow the editor's train of thought slowly and deeply, together to study and learn why C++ should not declare a class or enumerated value in a sentence and define the type of variable at the same time.

Do not declare a class or enumerated type in a statement and define variables of that type at the same time

Reason (reason)

Mixing the definitions of types and entities is difficult and unnecessary.

Translator's note: programming is not a flashy skill, and there is no need to change the code structure in order to reduce the number of lines.

Example, bad (negative example) struct Data {/ *... * /} data {/ * * /}; Example, good (good example) struct Data {/ *... * /}; Data data {/ *... * /}; Enforcement (implementation recommendation)

If the last} of the class or enumerated type definition is not immediately followed by;, or prompt when; is missing.

Thank you for your reading, the above is the content of "Why C++ should not declare a class or enumerated value in a sentence while defining this type of variable". After the study of this article, I believe you have a deeper understanding of why C++ should not declare a class or enumerated value in a sentence and define this type of variable at the same time, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report