#define in cpp
// The #define preprocessor directive creates symbolic constants
#include <iostream>
using namespace std;
#define CONSTANT 2.71828
int main () {
cout << "Declared constant: " << CONSTANT << endl;
return 0;
}
#define in cpp
// The #define preprocessor directive creates symbolic constants
#include <iostream>
using namespace std;
#define CONSTANT 2.71828
int main () {
cout << "Declared constant: " << CONSTANT << endl;
return 0;
}
c++ preprocessor commands
#include <iostream>
using namespace std;
#define PI 3.14159
int main () {
cout << "Value of PI :" << PI << endl;
return 0;
}
c++ what is #define
// #define is a macro that lets you use an alias name to
// make code more readable. During C++'s preproccessing stage, your macro
// will be replaced with the suitable code needed for proper compiling.
#include <iostream>
// used to define constants, types, functions and more....
#define SIZE 5
#define MacroInt int
#define getmax(a,b) ((a)>(b)?(a):(b))
int main(){
MacroInt myIntAsMacro = 7;
std::cout<< getmax(SIZE, myIntAsMacro); // will return 7
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us