Preprocessors
Preprocessors
Preprocessors
C++ Preprocessors
// macro definition
#define LIMIT 5
int main()
{
for (int i = 0; i < LIMIT; i++) {// LIMIT =5
std :: cout << i << "\n";
}
return 0;
}
The word ‘LIMIT’ in the macro definition is called a macro template and ‘5’ is
macro expansion.
Note: There is no semi-colon(‘;’) at the end of macro definition. Macro
definitions do not need a semi-colon to end.
Macros with arguments
• We can also pass arguments to macros. Macros defined with arguments works
similarly as functions. Let us understand this with a program:
#include <iostream>
// macro with parameter
#define AREA(l, b) (l + b) //LIMIT =5 AREA(10,4)
int main()
{
int l1 = 10, l2 = 5, area;
return 0;
}
File Inclusion
#include"filename“
#include”stringPro.cpp”
Conditional Compilation
#ifdef
macro_name
statement1;
statement2;
statement3; . . .
statementN;
#endif
2. Array is used for storing _________
• A. Operator
• b. Functions
• c. Objects
• d. Data types
10. When a class is defined inside any function or block, it is
called ___________ .
11. Logical expressions produce ____________ type results.
12. Static variable declared in a class are also called_________ .
12. If a class contains static variable, then every object of the
class has its copy of static variable.
a. True
b. False
13. __________________ is the OOP feature and mechanism
that binds together code and the data it manipulates, and
keep both safe from outside world.
14. ____________ refers to the act of representing only
essential features without including the background details.
15. Static variable must be declared in public section of the class.
Thank you