课程: Complete Guide to C++ Programming Foundations

免费学习该课程!

今天就开通帐号,24,100 门业界名师课程任您挑!

Variables

Variables

- [Instructor] There are a handful of important aspects about variables in C++. First and foremost, variables are temporary data storage units. They must be declared prior to being used. The declaration of a variable must specify a type and name. And declarations may contain initializations. In your code, you'll need to assign values to your variables. So let me briefly show you the syntax for representing values in some of the most popular types. Integer are entered as numbers with a special format for their ratings. The default is decimal, like 123, or minus five. A leading zero means octal, like 023. So be careful with this. For hexadecimal, start with 0x, like 0x3a. And for binary, start with 0b, as in 0b1100. You may specify unsigned with a trailing upper or lowercase U, as in 23U. Floats are entered with the decimal point and at least one digit to the right, even if the value happens to be an integer. And you must specify the float type with a trailing f, as in 23.0f, or 0.0f…

内容