当前位置:网站首页>宏定义使用以及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; \ };
边栏推荐
- 奋斗吧,程序员——第三十八章 旧时茅店社林边,路转溪头忽见
- IO之Reader案例
- GEE——Global Flood Database v1 (2000-2018)
- CF751 C. Optimal Insertion
- Certificate issuance process on aliyun OS (certbot)
- KNN classification of MATLAB (with source code) is used to realize pixel classification (set the proportion of training set by yourself) and print test accuracy
- Matlab的KNN分类使用(附源码),实现像素分类(自己设置训练集比例),打印测试精度
- 奋斗吧,程序员——第四十四章 八百里分麾下炙,五十弦翻塞外声
- The role of connect in the network
- 牛客挑战赛55E题解
猜你喜欢

"Dare not doubt the code, but have to doubt the code" a network request timeout analysis

Matlab的KNN分類使用(附源碼),實現像素分類(自己設置訓練集比例),打印測試精度

迪利克雷前缀和学习笔记

From prototype chain to inheritance, illustrate the context and recommend collection

APM flight mode switching -- source code explanation

Dirichlet prefix and study notes

在C#开发中使用第三方组件LambdaParser、DynamicExpresso、Z.Expressions,实现动态解析/求值字符串表达式

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

初识ElastricSearch

Two ways of traversing binary tree: preorder, inorder and postorder
随机推荐
How to improve customer conversion rate on the official website
IO之Buffered流案例
CF736 D2
Matlab的KNN分类使用(附源码),实现像素分类(自己设置训练集比例),打印测试精度
arc128 C 凸包优化后缀和?
Interpretation of basic requirements for classified protection of network security (GBT 22239-2019)
Niuke challenge 54F problem solution & Li Chaoshu's learning notes
Development technology of NFT trading platform digital collection system
Haas506 2.0 development tutorial - Advanced Component Library -modem Info (only supports versions above 2.2)
牛客挑战赛55D题解
[Software Engineering] Introduction & process and life cycle modeling
The role of connect in the network
Set up OpenPGP key server
Authenticated cookies, sessions, JWT
“不敢去怀疑代码,又不得不怀疑代码”记一次网络请求超时分析
Solution to 54e of Niuke challenge
lyndon分解学习笔记
In a word, several common methods of uploading Trojan horse
Niuke challenge 53e problem solution & Notes on learning with flowers and trees
Attack and defense drill | threat hunting practice case based on att & CK