C++ #define literals are not variables.

Description

C++ #define literals are not variables.

#include <iostream>
using namespace std;
#define X1 b+c//from   w ww . j  a v  a 2s.c om
#define X2 X1 + X1
#define X3 X2 * c + X1 - d
#define X4 2 * X1 + 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 << ", " << X1 << ", " << X2;
   cout << ", " << X3 << ", " << X4 << "\n";
   return 0;
}



PreviousNext

Related