backslash
-
Hi, I encounter such a problem as the usage of backslash '\' , follows are details
syntax
textline\For example,
#define DECLARE_DYNAMIC(class_name)\
public: \
static CRuntimeClass class##class_name; \
virtual CRuntimeClass *GetRuntimeClass() const;What does '\' mean here? Thank you in advance. Best regard. One concrete prolem is worth a thousand unapplied abstractions.
-
Hi, I encounter such a problem as the usage of backslash '\' , follows are details
syntax
textline\For example,
#define DECLARE_DYNAMIC(class_name)\
public: \
static CRuntimeClass class##class_name; \
virtual CRuntimeClass *GetRuntimeClass() const;What does '\' mean here? Thank you in advance. Best regard. One concrete prolem is worth a thousand unapplied abstractions.
A macro is a horrible construct left over from C. It basically means that where-ever MFC puts DECLARE_DYNAMIC(class_name), the code given is expanded out 'in place' by the preprocessor, with class_name replaced by whatever was passed in. To see why this is bad, consider a macro that takes a variable, x, and uses it three times in the expanded function, and what would happen if ++i was passed in as the value.... But in answer to your question, it allows the macro to be defined over multiple lines. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "But there isn't a whole lot out there that pisses me off more than someone leaving my code looking like they leaned on the keyboard and prayed that it would compile. - Jamie Hale, 17/4/2002
-
Hi, I encounter such a problem as the usage of backslash '\' , follows are details
syntax
textline\For example,
#define DECLARE_DYNAMIC(class_name)\
public: \
static CRuntimeClass class##class_name; \
virtual CRuntimeClass *GetRuntimeClass() const;What does '\' mean here? Thank you in advance. Best regard. One concrete prolem is worth a thousand unapplied abstractions.
It basically allows the statement from the previous line to continue to the next line. Mainly they are used in macros like Christian Graus has explained above. There are not very many other useful uses for this operator.
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!