#define PINT int * typedef int * PINT;的区别
来源:互联网 发布:数据库linit 编辑:程序博客网 时间:2024/06/05 03:13
PINT a,b;
翻译过来就是
int* a,b;
a是int型指针
b是int型数据
#define 是宏命令,在编译前,由预处理器做替代,如同文本编辑的替代命令,把程序中的所有遇到的词,全部替代。
#define PINT int*
就是把所有的词 PINT 替换成 int * ,替换完毕再编译。
typedef int* pint; 是语句,由编译器在编译过程中编译处理。int* x; 和pint x; 的声明是等价的。在typedef int* pint中long int* x; 声明是可以的,但long pint x; 不可以。而在#define PINT int* long int* x; 声明是可以的,long PINT x; 也是可以的。
typedef的用法
在C/C++语言中,typedef常用来定义一个标识符及关键字的别名,它是语言编译过程的一部分,但它并不实际分配内存空间,实例像:
typedef int INT;
typedef int ARRAY[10];
typedef (int*) PINT;
typedef可以增强程序的可读性,以及标识符的灵活性,但它也有“非直观性”等缺点。
#define的用法
#define是预处理指令,在编译预处理时进行简单的替换,不作正确性检查,不关含义是否正确照样带入,只有在编译已被展开的源程序时才会发现可能的错误并报错。例如:
#define PI 3.1415926
程序中的:area=PI*r*r 会替换为3.1415926*r*r
如果你把#define语句中的数字9 写成字母g 预处理也照样带入。
两者的区别:
typedef (int*) PINT;
#define PINT2 int*
PINT a,b;的效果同int *a; int *b;表示定义了两个整型指针变量。而PINT2 a,b;的效果同int *a, b;
表示定义了一个整型指针变量a和整型变量b。
- typedef int* PINT与#define PINT int*的区别
- #define PINT int * typedef int * PINT;的区别
- #define int *PINT和typedef int*PINT
- #define PINT int*与typedef int *SINT的区别.
- #define PINT int * 与 typedef int * SINT;
- #define PINT int* typedef int *SINT
- #define PINT int * typedef int * SINT; 这两的区别及define与undefine用法
- 作业1.#define PINT int * 2.typedef int * SINT;
- int* pInt = new int(5)和int* pInt = new int[5]的区别
- int* pInt = new int(5);和int* pInt = new int[5];
- int* pInt = new int(5);和int* pInt = new int[5];
- int * const a, 和 const int* a,const PInt a;
- typedef interrupt void (*PINT)(void);
- typedef int * q与#define p int*区别
- java实现的pint命令
- typedef-------typedef void (*sighandler_t)(int)的区别
- (int) &、(int)、(int &)的区别
- #define a int[10] typedef int a[10]
- Markdown 语法说明
- [最小费用最大流]BZOJ 1070 [SCOI2007]——修车
- 习题五
- 深度学习loss函数理解
- Java后台框架篇--Spring的AOP实现原理
- #define PINT int * typedef int * PINT;的区别
- linux进程如何捕捉信号
- 三极管当做开关的导通方式
- Servlet基本概念和流程
- Ubuntu -超级管理员root 登录
- Python 硬盘模式读取文件,保存内容到文件
- 那些奇技淫巧
- Db2 之 Merge Into语句详解
- iframe与主框架跨域相互访问方法