// 宏试验.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include <string>
using namespace std;
//宏定义
#define hong1 1;
//宏函数
#define hong2(a) a*a
//连接字符串
#define hong3(a,b) a##b
//把数字变成字符串
#define hong4(a) #a;
//把数字变成字符
#define hong5(a) #@a;
#define hong6(a,...) hong6_2(a,hong1)
#define hong6_2(a,b) a##b
#define myprintf(templt, ...) fprintf(stderr,templt, ##__VAR_ARGS__)
int main()
{
cout << "Hello World!\n";
cout << hong1;
cout << "\n";
cout << hong2(5) << "\n";
cout << hong3(5, 6) << "\n";
cout << hong3("A", "b") << "\n";
string str = hong4(5);
cout << str + "\n";
char char1 = hong5(5);
cout << char1 + "\n";
// myprintf(5);
//cout << hong6(5, ...) << "\n";
}
c++ 宏 试验
最新推荐文章于 2025-12-12 16:37:00 发布
1万+

被折叠的 条评论
为什么被折叠?



