#include#include #define DEBUG_MODE // Use debug mode int main() { #ifdef DEBUG_MODE std::cerr << "This is a debug message" << std::endl; #endif std::cout << "Program ended successfully!" << std::endl; return 0; }
#includeIn this example, the preprocessor is used to define a macro that calculates a number cubed. The value of the macro is then assigned to a variable and printed to the console during runtime. Package/library: Standard C++ Library#define CUBED(x) x*x*x int main() { int num = 2; int cubed = CUBED(num); std::cout << "The cube of " << num << " is " << cubed << std::endl; return 0; }