If we declare two macro with the same identifier without
doing undef the first, what will be the result?
eg: #define MAX_SIZE 100
#define MAX_SIZE 200
int table1[MAX_SIZE];
Answer Posted / binoy mathew
#include <iostream>
#include <stdlib.h>
#define max 100
#define max 200
int main()
{
printf("%d",max);
return 0;
}
save and run.
[root@localhost Desktop]# g++ test.cpp
test.cpp:5:1: warning: "max" redefined
test.cpp:4:1: warning: this is the location of the previous
definition
[root@localhost Desktop]# ./a.out
200
it shows a warning, but the value used is the latest.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How a pointer differs from a reference?
How do I download c++?
In what situations do you have to use initialization list rather than assignment in constructors?
Explain virtual class and friend class.
what is upcasting in C++?
Why should we use null or zero in a program?
Mention the purpose of istream class?
What is do..while loops structure?
What is the difference between cin.read() and cin.getline()?
What's c++ used for?
What is the use of main function in c++?
When should we use container classes instead of arrays?
Write a program to encrypt the data in a way that inputs a four digit number and replace each digit by (the sum of that digit plus 7) modulus 10. Then sweep the first digit with the third, second digit with the fourth and print the encrypted number.
what is multi-threading in C++?
Write a Program to find the largest of 4 no using macros.