+ 4

What is the role of #define in c++?

29th Dec 2016, 7:47 AM
Ledja Kanani
Ledja Kanani - avatar
9 Réponses
+ 5
#define is a shortcut for a value that is used over and over in your code. For example: you #define TAX as 20 and from now on, instead of saying 20, you just say TAX. example: i = 300 + 20 is the same as i = 300 + TAX
29th Dec 2016, 12:12 PM
Shahar Levy
Shahar Levy - avatar
+ 3
In c++ there are some pre processor directives like we always use header file #include. Like this #define is also an preprocessor directive and with the help of which we create symbolic constants and these constant are known as macros
29th Dec 2016, 8:27 AM
Amandeep Saluja
Amandeep Saluja - avatar
+ 2
It is used to define a macro in c++. Mostly used to make changes in our code at last moment .
29th Dec 2016, 8:16 AM
Amandeep Saluja
Amandeep Saluja - avatar
+ 1
Thank you :)
29th Dec 2016, 8:29 AM
Ledja Kanani
Ledja Kanani - avatar
+ 1
welcome
29th Dec 2016, 8:30 AM
Amandeep Saluja
Amandeep Saluja - avatar
+ 1
sorry but I have little bit of knowledge about C++.
29th Dec 2016, 9:08 AM
Ajay Agrawal
Ajay Agrawal - avatar
0
@Amandeep Saluja what is a macro?
29th Dec 2016, 8:19 AM
Ledja Kanani
Ledja Kanani - avatar
0
@Shahar Levy thank you :) @Ajay It is a pleasure for me too.
29th Dec 2016, 12:33 PM
Ledja Kanani
Ledja Kanani - avatar
0
#define is one of the preprocessors in C++ to define a variable as constant and which the varible can be use anywhere in the program.
30th Dec 2016, 11:41 AM
OMOTAYO EMMANUEL OLADAPO
OMOTAYO EMMANUEL OLADAPO - avatar