Types of | Keyword |
---|---|
Boolean | bool |
Integer | int |
Single precision | float |
Double precision | double |
No return value type | void |
Wide character | wchar_t |
C++ sizeof to obtain the size of various data types
#include<limits>
cout<<(numeric_limits<int>::max)() << '\t'<<(numeric_limits<int>::min)()<< endl;
For the understanding of C++, all the header files are introduced.
The limits header file has a numeric_limits method.
Custom data type
typedef declaration (can be understood as alias)
typedef int hello;
hello a=3;
cout<<a<<endl;
Enumeration types are derived from C++
enum color{
red,blue,green};
enum color {
red,blue,yellow} abs;
abs=yellow;
cout<< abs <<endl;
输出-------------------
2
解释:输出第一个名称的值为 0,第二个名称的值为 1,第三个名称的值为 2
假如:blue=3,结果为4