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

How to understand C++ programming technology

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "how to understand C++ programming technology". In the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

We explain the program line by line:

(1) the * * line is a comment for the C++ language. Where "/" is a comment symbol in C++ language, and everything is treated as a comment from "/" to the end of this line. C++ programming techniques can also be written in the following form: both forms of annotations are often used when we are programming. The difference is that the former can only comment on one line of content, while the latter can comment on multiple lines. It can be used anywhere in the program, and the compiler ignores this information when compiling. Comments are used to help read and understand the program, and comments can also be used to help users debug the program.

(2) Line 2 uses the preprocessing directive # include to include the header file iostream.h, the standard C++ header file, iostream.h, which contains the definitions of input and output.

(3) Line 3 defines a function called main. A function has 0 or more arguments that appear in a pair of parentheses after the function name. The void in parentheses indicates that main has no parameters. A function can have a return type, which is to the left of the function name.

(4) Line 4 is a curly bracket that marks the beginning of the body of the main function.

(5) Line 5 is a statement.

A statement may define or declare a variable, or it may be a step to get a numeric value. A statement ends with a semicolon (;), and a semicolon separates the statement with a semicolon. This statement defines an integer variable I. A variable can hold a specific type of data, and an integer variable can hold an integer data.

(6) Line 6 is also a statement. This statement takes the string "Hello clipped!" A string sent to the cout output stream is a series of characters enclosed in double quotes.

(7) Line 7 is also a statement. This statement sends the string "Please enter an integer:" to the cout output stream. A character (\ n) of a string is a newline character. A stream is an object that performs input and output. Cout is the C++ standard output stream, and standard output usually refers to the computer screen.

A symbol is an input operator with an input stream as its left Operand and a variable as its right Operand. The former is extracted to the latter, and the effect of cin input stream extraction to variable I is to copy the keyboard input value to variable I.

(9) Lines 9, 10 and 11 print "the integer you entered is:", the variable I, and the newline character on the screen, respectively. These three lines can actually be combined into a single statement: cout

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

Development

Wechat

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

12
Report