typedef
来源:互联网 发布:儿童初学画画软件 编辑:程序博客网 时间:2024/06/14 10:18
使用typedef为现有类型创建同义字,定义易于记忆的类型名
typedef int size;void measure(size*psz);size array[4];size len=file.getlength();std::vector<size>vs;
typedef 还可以掩饰复合类型,如指针和数组。
例如,你不用像下面这样重复定义有 81 个字符元素的数组:
typedef charLine[81];Line text,line;getline(text);定义函数指针
#include<iostream>using namespace std;typedef int(*pf)(int, int);int sum(int a, int b){return (a + b);}int main(){int a = 3;int b = 1;pf myfun;//int(*myfun)(int a,int b); //定义函数指针myfun = sum; //给函数指针赋值cout << myfun(a, b) << endl;system("pause");return 0;}
同样,可以像下面这样隐藏指针语法:
typedef char* pstr;int mystrcmp(const pstr p1,const pstr p3);
阅读全文
0 0
- typedef
- typedef
- typedef
- typedef
- typedef- -
- typedef
- typedef
- typedef
- typedef
- typedef
- Typedef
- typedef
- typedef
- typedef
- typedef
- typedef
- typedef
- typedef
- PAT 1002. A+B for Polynomials
- SpringMVC IOC DI接口版本管理(迭代版)
- 7.1—查找—Sear for a Range
- HDU 1535 Invitation Cards(多源点到单源点,dijkstra/spfa)
- 闲记
- typedef
- python 安装superset:error: Setup script exited with error: command 'gcc' failed with exit status 1
- 小白如何成长为优秀的系统设计专家?
- 7.2—查找—Sear Insert Position
- 剑指offer-39.二叉树的深度
- 关于日间夜间模式切换的一种实用方法
- 7.3—查找—Sear a 2D Matrix
- 框架就快开源了
- 使用若要打开fc-list,您需要安装X11