标签:种类 rgba ret turn ble space 语法 style 结果
typedef - 自定义类型
该语句主要用于将某种类型起名为一个别名,如 double 起名为 area,这样以后再定义area类型的变量时,就相当于定义了一个double的变量。
程序实例:
定义一个double 类的
#include <iostream> using namespace std; int main() { typedef double area, volume; area A1 = 3.23; volume V1 = 100.32; cout << "the size of area= " << sizeof A1 <<"bytes"<<"\n" ; cout << "the size of volume= " << sizeof volume << "bytes"<< "\n"; return 0; }
the size of area= 8bytes
the size of volume= 8bytes
也可以使用C 语言继承过来的using
语法说明:
using(新类型名称=已有类型明)
#include <iostream> using namespace std; int main() { using area=double; using volume = double; area A1 = 3.23; volume V1 = 100.32; cout << "the size of area= " << sizeof A1 <<"bytes"<<"\n" ; cout << "the size of volume= " << sizeof volume << "bytes"<< "\n"; return 0; }
运行结果:
the size of area= 8bytes
the size of volume= 8bytes
标签:种类 rgba ret turn ble space 语法 style 结果
原文地址:https://www.cnblogs.com/datawork/p/14399915.html