Web Developer wrote:
Hi,
What are Macros in C++?
A macro is only slightly better than the "find and replace" function of
most text editors. If I define a macro like this:
#define SOME_MACRO some text
Then every occurrence of SOME_MACRO in the source that follows will be
replaced with "some text" (without the quote marks). There are
exceptions, though. If the code that follows contains this:
cout << "SOME_MACRO" << endl;
The substitution does not occur in this case because the SOME_MACRO is
inside a string literal.
You can also have parameterized macros that act somewhat like inlined
functions.
Use of macros is discouraged in C++. They are dangerous and rarely
necessary.
You should be able to read all about this in your C++ book. Why didn't
you? I guarantee you that you cannot learn C++ from a newsgroup.
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.