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

Why c++ does not have finally?

715


Write is a binary search tree? Write an algo and tell complexity?

690


Why null pointer is used?

675


What is object in c++ example?

709


Why is main an int?

620






What language is a dll written in?

620


What is vectorial capacity?

773


what is upcasting in C++?

825


What is the difference between passing by reference and passing a reference?

658


Is swift faster than go?

717


What is function overriding in c++?

686


What is a namespace in c++?

707


What is purpose of new operator?

686


Which format specifier is used for printing a pointer value?

668


What is c++ programming language?

692