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

Is there a new/delete equivalent of realloc?

1 Answers  


What is an operator in c++?

0 Answers  


Can notepad ++ run c++?

0 Answers  


Explain what are mutator methods in c++?

0 Answers  


How does code-bloating occur in c++?

0 Answers  






string somestring ; Which of the following choices will convert a standard C++ string object "somestring" to a C string? a) Copy.somestring () ; b) somestring.c_str () c) &somestring [1] d) std::cstring (somestring) e) (char *) somestring

1 Answers   Quark,


What are c++ variables?

0 Answers  


What does new in c++ do?

0 Answers  


What are the stages in the development cycle?

0 Answers  


What is searching?

0 Answers  


Why do we use vector in c++?

0 Answers  


Can constructor be static in c++?

0 Answers  


Categories