3章5节typ创建别名

来源:互联网 发布:手机淘宝物流查询 编辑:程序博客网 时间:2024/05/22 09:44

#include <iostream>

int main()
{
 using std::cout;
 using std::endl;

 short unsigned int width = 5, length;
 length = 10;
 // 定义变量和赋值变量可以一次多个 并可以混合

 unsigned short int area = (width * length);

  cout << " width = " << width << endl;
     cout << " length = " << length << endl;
  cout << " area = " << area << endl;
  return 0;
}*/
#include <iostream>

int main()
{
 typedef unsigned short int USHORT; // USHORT as a defined type
 using std::cout;
 using std::endl;

 USHORT width = 5, length;    // 应用了USHORT(这个名字是自定义的) 代表了 unsigned short int
 length = 10;
 // 定义变量和赋值变量可以一次多个 并可以混合

 USHORT area = (width * length);

  cout << " width = " << width << endl;
     cout << " length = " << length << endl;
  cout << " area = " << area << endl;
  return 0;
}

原创粉丝点击