I want to know the meaning of the code “\”. I have seen some explanation before, but I forget, who can tell me?
#include "stdafx.h"
#include <fstream>
using namespace std;
ofstream out("order.out");
#define CLASS(ID) class ID {\
public: \
ID(int) { out<<#ID " constructor\n;} \
~ID() { out<< #ID "destructor\n";}\
};
It makes the compiler see the current line and the line after
\as the same line.For defines this is important, as the preprocessor only takes into account what’s on the current line.
For example:
would expand to
whereas
would expand to