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 do nonglobal variables default to a) auto b) register c) static

920


What is the full form of ios?

764


Describe about storage allocation and scope of global, extern, static, local and register variables?

1022


what is scupper?

2097


Explain what are mutator methods in c++?

790


What's the "software peter principle”?

846


What is c++ stringstream?

880


Why do we use templates?

815


What are the restrictions apply to constructors and destructors?

853


Define anonymous class.

818


How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?

1047


which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?

976


Explain the difference between static and dynamic binding of functions?

818


Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.

883


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

796