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 do I tokenize a string in c++?
What is the main function c++?
What do you mean by const correctness?
Why is c++ still popular?
What are enumerations?
Explain the concept of memory leak?
Is c++ an oop?
What is ofstream c++?
What are the sizes and ranges of the basic c++ data types?
What is the use of this pointer in c++?
Explain function overloading
What are the three forms of cin.get() and what are their differences?
What is the use of lambda in c++?
Is atoi safe?
Explain what is polymorphism in c++?