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

Why should you learn c++?

0 Answers  


Write the program for fibonacci in c++?

20 Answers   TATA, Wipro,


What is the difference between prefix and postfix versions of operator++()?

0 Answers  


What is vector processing?

0 Answers  


What is static function and static class?

4 Answers   HCL,






Can a program run without main function?

0 Answers  


Ask to write virtual base class code?

0 Answers   Satyam,


write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.

0 Answers  


Can we make copy constructor private in c++?

0 Answers  


Define friend function.

0 Answers  


What are the general quetions are in DEna bank manager IT/System interviews?

0 Answers   Dena Bank, ICICI,


I was a c++ code and was asked to find out the bug in that. The bug was that he declared an object locally in a function and tried to return the pointer to that object. Since the object is local to the function, it no more exists after returning from the function. The pointer, therefore, is invalid outside.

0 Answers  


Categories