12:typedef初级使用

来源:互联网 发布:七妹电音软件 编辑:程序博客网 时间:2024/05/29 12:54
#include <iostream>
using namespace std;:

typedef int 考试分数;
typedef int exam_socre;

typedef double wages;
typedef wages  salary;

typedef double 工资;
typedef 工资  薪资;

//////////
#define MAXSIZE 50

typedef int keytype;
typedef double valtype;
typedef struct
{
keytype  key;
valtype  val;
}  DataType;

typedef struct
{
DataType data[MAXSIZE];
int length;
} SqList;

int main()
{
//1,可以把一些复杂的类型隐藏起来
//使用简单的名字,比如结构体等
//2,简化复杂类型的定义,使其更容易理解
//3,允许一种类型用于多个目的,使得每一次使用目的明了
int         a;
考试分数    b;
exam_socre  c;

double  k;
    工资  m, 时薪, 周薪;
wages  hour, week;

时薪 = 50.00;
周薪 = 500.00;

cout<<时薪<<endl;
cout<<周薪<<endl;

///////////////
system("pause");
return 0;
}
0 0
原创粉丝点击