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
What do nonglobal variables default to a) auto b) register c) static
What is the full form of ios?
Describe about storage allocation and scope of global, extern, static, local and register variables?
what is scupper?
Explain what are mutator methods in c++?
What's the "software peter principle”?
What is c++ stringstream?
Why do we use templates?
What are the restrictions apply to constructors and destructors?
Define anonymous class.
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?
which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
Explain the difference between static and dynamic binding of functions?
Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.
What is the difference between passing by reference and passing a reference?