- #include <iostream>
- usingnamespace std;
- intmain ()
- {
- #define MODI 10
- cout << MODI << endl;
- #undef MODI
- cout << MODI + 1 << endl;
- return 0;
- }
The reason is what #undef does:
When you run out of a macro, such as MODI, you don't want the following code to use this MODI, then you can #undef it, then if you use the MODI macro again, the compiler will report an error.
A common practice is:
- #define MAX 50
- #include "common.h"
- #undef MAX
This makes the macro MAX available only in common.h.