90 Introduction to C++ Programming and Graphics
cout << square(e);
cout << endl;
prints on the screen:
25
Two further uses of thedefinedirective are illustrated in the following
example:
#define andykaufman(x) #x;
cout << andykaufman(genius) << endl;
#define gatoula(x,y) x ## y;
int iatros = 10;
cout << gatoula(ia,tros) << endl;
which prints on the screen:
genius
10
The first directive places the variablexbetween double quotes. The second
directive glues together the strings represented byxandy. Other preprocessor
directives will be discussed in Chapter 5.
Problems
3.10.1. Define a macro so that the following command makes sense:
enter a;
3.10.2. Define a macro so that the following command makes sense:
We will now print the value of x;