C++第二章理论题经验整理2

287.e2 is a valid floating-point literal.

The range of floating-point numbers in C++: -3.4E+38 to +3.4E+38

Float for single precision, double for double precision and long double for extended precision.

Float store floating point numbers with 8 place accuracy and requires 4 bytes of Memory. Double has 16 place accuracy having the size of 8 bytes.

setprecision(17)之后,搞出来的精度就是17位的。

float i = 123.0f;
cout << i << endl;

上述代码输出的是123. (0f表示输出的精度)

0.5f results in 0.5 to be stored in floating point representations.

char types in C++ require atleast 8 bits and short requires atleast 16 bits, whereas for bool only 1 bit suffices and both int and float requires atleast 32 bits.

The limit header holds the details of the machine dependent details.

Each object in C++ is expressed in terms of char type and size of char type is one byte.

32-bit systems:char:1 int:4 float:4

Constructor creates an Object and Destructor destroys the object. They are not supposed to return anything, not even void.

There are no void objects.

enumerators are same as macros:Enumerators are used in order to create our own types whereas macros are textual substitutions.

In C++, enumerations are stored as integers by the compiler starting with 0.

Since enumerators evaluate to integers, and integers can be assigned to enumerators, enumerators can be assigned to other enumerators.

Enumerator will allocate the memory when its variables are defined.

If we not assigned any value to enum variable means, then the next number to initialized number will be allocated to the variable.

Enumeration variable ‘star’ appears two times in main() which causes the error. An enumaration constant must be unique within the scope.

原文地址:https://www.cnblogs.com/hhlys/p/13443538.html