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


Please Help Members By Posting Answers For Below Questions

What is a manipulator in c++?

711


Difference between pointer to constant and constant pointer to a constant. Give example.

642


Which software is best for coding?

572


Why do we use structure in c++?

572


Describe linked list using C++ with an example.

647






What is a c++ object?

617


Explain about vectors in c ++?

593


Is map ordered c++?

593


What is the default width for ouputting a long integer using the insertion operator?

687


Which software is best for programming?

659


Describe the role of the c++ in the tradeoff of safety vs. Usability?

711


What is the full form nasa?

595


Mention the ways in which parameterized can be invoked. Give an example of each.

570


What is the auto keyword good for in c++?

622


What are disadvantages of pointers?

565