C++/macros in c++
what is the purpose of macros in c++?
and how can i use a macro from another file/program?
> what is the purpose of macros in c++?
macros are a type-unsafe feature of the C preprocessor and are considered avoidable in most situations by by C++ experts. see:
in general, the thumb-rule is if there is an equivalent compiler feature available, prefer that to a preprocessor technique.
places where macros are un-avoidable are places where you need to refer to tokens in your source file. a good example is the assert macro in <cassert> which needs to know about the file name, line number and the text of the assertion.
> and how can i use a macro from another file?
only by #including the file; remember, it is a preprocessor technique.
> and how can i use a macro from another program?
obviously this is not possible other than by using the source file (typically a header) that defined the macro.