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];

Answers were Sorted based on User's Feedback



If we declare two macro with the same identifier without doing undef the first, what will be the r..

Answer / ahmed

It will be 200
This is why #define is considered as unsafe type when
compared to const variables

Is This Answer Correct ?    9 Yes 0 No

If we declare two macro with the same identifier without doing undef the first, what will be the r..

Answer / 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

If we declare two macro with the same identifier without doing undef the first, what will be the r..

Answer / sourisengupta

Thanx Ahmed

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is c++ prototype?

0 Answers  


why can't we declare data member of class auto register or extern

1 Answers  


What is difference between c++ and c ++ 14?

0 Answers  


If dog is a friend of boy, is boy a friend of dog?

0 Answers  


How do I make turbo c++ full screen?

0 Answers  






Explain the register storage classes in c++.

0 Answers  


Write a c++ code that will calculate the roots of a quadratic equation a2+ bx+c=0 Hint: d = sqrt (b2-4ac), and the roots are: x1 = (€“b + d)/2a and x2 = (€“b €“ d)/2a (use sqrt function from cmath.h )?

0 Answers   Maxobiz,


What is the basic of c++?

0 Answers  


Write a Program for read a line from file from location N1 to N2 using command line arguments. Eg:exe 10 20 a.c

0 Answers  


show that among any group of five (not necessary consecutive ) integers, there are two with the same remainder when divided by 4.

1 Answers  


What is late binding c++?

0 Answers  


Can we define function inside main in c++?

0 Answers  


Categories