类型 | 关键字 |
---|---|
布尔型 | bool |
整型 | int |
单精度 | float |
双精度 | double |
无返回值类型 | void |
宽字符型 | wchar_t |
c++中sizeof获取各种数据类型的大小
#include<limits>
cout<<(numeric_limits<int>::max)() << '\t'<<(numeric_limits<int>::min)()<< endl;
对c++的理解,引入的都是头文件。
limits 头文件,有numeric_limits方法。
自定义数据类型
typedef 声明(可理解为别名)
typedef int hello;
hello a=3;
cout<<a<<endl;
枚举类型是C++派生的类型
enum color{
red,blue,green};
enum color {
red,blue,yellow} abs;
abs=yellow;
cout<< abs <<endl;
输出-------------------
2
解释:输出第一个名称的值为 0,第二个名称的值为 1,第三个名称的值为 2
假如:blue=3,结果为4