What are C++ Preprocessor Operators?
Following preprocessor operators are available in C++ that could be used with the #define directive.- # is stringify operator turns the operand into a string. Can be used only in macro replacement text. Macro parameter name must follow this operator.
- ## is concatentation operator to cat preprocessor tokens. Can be used only in macro replacement text. Must not appear in the beginning or end of replacement text.
Demonstrate the usage of preprocessor operators
#include <iostream>OUTPUT:-
using namespace std;
#define myprint1(a) cout << #a << endl
#define myprint2(a,b) cout << a##b << endl
int main()
{
myprint1(hello);
myprint2("hello","world");
return 0;
}
hello
helloworld
0 comments:
Post a Comment