当前位置:网站首页>宏定义使用以及typedef和const
宏定义使用以及typedef和const
2022-06-22 11:28:00 【悠然少年心】
typedef可以用来定义一些自己的类
const定义固定值无法修改
typedef int zhengxing;
zhengxing u = 10;
printf("%i \r\n", u);//10
const int i = 10;
i = 5;//报错
第一个#if #endif 如果if后面的条件为真就编译他们之间的代码 反之就不编译
#if 0
char* ptr_size;//32位机: 4字节 64位机: 8字节
printf("%d \n",sizeof(ptr_size));
#endif // 0
第二个:#define
#define num(a,b) a+b
int a = num(1, 3);
printf("%i", a);
第三个 用#define 定义函数或者类
//这个## 是连接字符串的作用
//这里可以用于把FunName这个形参和其他内容连接起来
#define num1(FunName,a,b) \ int FunName##_Hello(int a,int b) \ {
\ return a+b;\ }
num1(III, x, y);
int main()
{
int e=III_Hello(1, 2);
printf("%i \r\n", e);
}
//宏定义一个类
#define num2(FunName,astring) \ class CCC_##FunName \ {
\ public: \ CCC_##FunName() \ :a(#astring) \ {
} \ char a; \ };
边栏推荐
- Niuke challenge 53c
- 关于缓存异常:缓存雪崩、击穿、穿透的解决方案
- 国外LEAD需要干劲、兴趣、钻研、勤奋、缺一不可
- R语言使用read.table加载条件logistic回归分析的数据集(csv数据)、使用unique函数查看配对数据有多少组
- 常见面试题目解答之cookie和session
- PHP database mysql question
- IO buffered stream case
- Solution to 94d problem of Niuke practice match
- CF751 C. Optimal Insertion
- Obtain the public IP address summary under the command line
猜你喜欢

How many of the eight classic MySQL errors did you encounter?

Puzzle (019) plane forward problem
![[2206] An Improved One millisecond Mobile Backbone](/img/75/b040f4b88050937dee57003b62f7b0.png)
[2206] An Improved One millisecond Mobile Backbone

关于缓存异常:缓存雪崩、击穿、穿透的解决方案

NFT交易平台数字藏品系统开发技术

SPI 与 API的区别

2022 the latest software testing classic summarized by major manufacturers. After reading it, I'm not afraid I won't get an offer

初识ElastricSearch

牛客挑战赛53C

APM flight mode switching -- source code explanation
随机推荐
Noun analysis: ETL
electron添加SQLite数据库
“中国巴菲特”段永平:投资有道
Development technology of NFT trading platform digital collection system
xlrd. biffh. XLRDError: Excel xlsx file; Not supported solution
Reader case of IO
PHP database mysql question
R language performs two sample t-test on the specified covariates based on the with function, and the t.test function performs Welch two sample t-test analysis and two independent sample t-test on the
IO之ByteArrayStream案例
CF736 D2
TCP connection establishment process (in-depth understanding of the source code and three handshakes)
IO之Buffered流案例
R language uses user-defined functions to write in-depth learning parametric relu activation functions and visualize parametric relu activation functions
GEE——Global Flood Database v1 (2000-2018)
From prototype chain to inheritance, illustrate the context and recommend collection
Electron adding SQLite database
What is homology??? Cross domain error??? How to solve???
The use of cellstr function in MATLAB
奋斗吧,程序员——第四十一章 今日种种,似水无痕;明夕何夕,君已陌路
鉴权之cookie、session、JWT