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];
Answers were Sorted based on User's Feedback
Answer / 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 |
Why should you learn c++?
Write the program for fibonacci in c++?
What is the difference between prefix and postfix versions of operator++()?
What is vector processing?
What is static function and static class?
Can a program run without main function?
Ask to write virtual base class code?
write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.
Can we make copy constructor private in c++?
Define friend function.
What are the general quetions are in DEna bank manager IT/System interviews?
I was a c++ code and was asked to find out the bug in that. The bug was that he declared an object locally in a function and tried to return the pointer to that object. Since the object is local to the function, it no more exists after returning from the function. The pointer, therefore, is invalid outside.