#号后跟着的都属于宏;
如:#include 、#define
宏就是把宏后边的代码展开;
举个例子:
/*-----------test.h-----------*/
#ifndef TEST_H
#define TEST_H
#define STRING "string" //相当于“string”这个字符串赋值给了STRING
class Test
{
public:
Test();
~Test();
};
#endif // TEST_H
/*-----------Main-------------*/
#include <iostream>
#include <string.h>
#include <test.h>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
char str[] = STRING;//这里就相当于 char str[] = "string";
cout << "str = " << str <<endl;
return a.exec();
}