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 can’t you call invariants() as the first line of your constructor?

803


Is facebook written in c++?

790


what is a reference variable in C++?

950


Explain virtual class and friend class.

824


What is an adjust field format flag?

919


Can we distribute function templates and class templates in object libraries?

828


How do you clear a map in c++?

857


What is the use of data hiding?

811


How is c++ used in the real world?

812


How do I write a c++ program?

843


What is #include c++?

804


What do you mean by global variables?

878


What are the uses of static class data?

919


What is a singleton class c++?

798


What do you mean by late binding?

869