Interview Questions

Differences of C and C++ Could you write a small program that will compile in “C” but not in “C++”?

C++ Interview Questions and Answers


(Continued from previous question...)

Differences of C and C++
Could you write a small program that will compile in “C” but not in “C++”?

In C, if you can a const variable e.g.
const int i = 2;
you can use this variable in other module as follows
extern const int i;
C compiler will not complain.

But for C++ compiler u must write
extern const int i = 2;
else error would be generated.

(Continued on next question...)

Other Interview Questions