Illustrates that #define literals are not variables. - C++ Preprocessor

C++ examples for Preprocessor:Directive

Description

Illustrates that #define literals are not variables.

Demo Code

#include <iostream>
using namespace std;
#define X2 b+c + b+c/* w ww. j  a  v  a2s.co  m*/
#define X3 X2 * c + b+c - d
#define X4 2 * b+c + 3 * X2 + 4 * X3
int main()
{
   int b=2;     // Declares and initializes four variables.
   int c=3;
   int d=4;
   int e=X4;
   // Prints the values.
   cout << e << ", " << b+c << ", " << X2;
   cout << ", " << X3 << ", " << X4 << "\n";
   return 0;
}

Result


Related Tutorials