概述:##的作用是连接,那么宏的做用是什么呢,宏运行的结果是什么呢,我们可以把他理解为可以生产源代码。
个人理解:c++没有反射,宏可以实现一些类似反射的机能。
简单实验
#include <iostream>
#define funw1(i) sa##i
struct A {
int a;
int b;
}sa1,sa2;
int main()
{
funw1(1).a = 1;
funw1(2).a = 1;
int a = 5;
std::cout << "Hello World!\n";
}
运行结果