In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what C++ commonly used sentences, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
1. Declare variables
In C++, all variables need to be declared, such as:
Int wordCnt
We declare a variable wordCnt of type int, which tells the compiler two key pieces of information. One is the memory required by the variable, and the other is the name of the block of memory. For example, in this example, we declare an int variable. It occupies 32 binary bits, or 4 bytes, and this block of memory is called wordCnt.
Note: in some languages (such as basic), variables do not need to be declared and can be used directly. But this can cause some problems, such as difficult to check when there is a spelling mistake.
For variable declarations, C++ Primer recommends that you declare a variable before you use it for the first time, whenever possible.
2. Assignment statement
After the variable is declared, we can assign it the value we want through the assignment statement.
For example:
WordCnt = 10
Continuous assignment is supported in C++, for example:
Int wordCnt;int personCnt;int roomCnt;wordCnt = personCnt = roomCnt = 10
This is a continuous assignment, with 10 first assigned to the rightmost roomCnt, then to personCnt, and finally to wordCnt.
3. Cin, cout statement
Cin and cout are also commonly used sentences in C++.
Cin, as its name implies, means read in. It can read data from the screen (terminal) and flow to the variables we specify.
For example:
Int wordCnt;cin > > wordCnt
Cin is the object that inputs data, and the data flows from cin to wordCnt. That is, the data we input at the terminal is read into the wordCnt.
Like cout, we can read many types of data from the terminal, such as floating point numbers, integers, strings, etc. Cin will automatically convert the read data into the corresponding data type and complete the assignment.
When we use cout to output results, we can use multiple
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.