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 happens when the extern "c" char func (char*,waste) executes?

640


how to access grid view row?

1814


Explain function overloading and operator overloading.

626


What is vector pair in c++?

712


Which is not an ANSII C++ function a) sin() b) tmpnam() c) kbhit()

1009






Is there any difference between int [] a and int a [] in c++?

555


What is a c++ class?

625


Can the creation of operator** is allowed to perform the to-the-power-of operations?

582


Differentiate between late binding and early binding.

644


Write about the stack unwinding?

630


What is endianness?

624


What information can an exception contain?

669


What is while loops?

619


When is the destructor called?

608


Comment on assignment operator in c++.

713