English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

it is a interview question

2007-03-17 00:11:12 · 4 answers · asked by engg 1 in Computers & Internet Programming & Design

4 answers

From Page 26 of C++ Complete Reference Third Edition:

Because C/C++ allows separate modules of a large program to be separately compiled
and linked together, there must be some way of telling all the files about the global
variables required by the program. Although C technically allows you to define a
global variable more than once, it is not good practice (and may cause problems when
linking). More importantly, in C++, you may define a global variable only once.

2007-03-17 00:55:32 · answer #1 · answered by Murali 1 · 0 0

Sure, anything that has been changed in C++ from C will affect the code.

Case in point:
int p = malloc(sizeof p).

Standard malloc idiom in C. You normally use new in C++, but if you tried to do the above malloc in C++ you would get a compile error on incompatible types. You need an explicit cast in C++.

2007-03-17 14:55:05 · answer #2 · answered by csanon 6 · 0 0

No, Nothing in C doesn't work under C++.
Any C Code works 100% under C++.

2007-03-17 03:32:03 · answer #3 · answered by Coosa 2 · 0 1

No, C++ is completely compatible with C. Linking is another issue, though.

2007-03-17 02:06:58 · answer #4 · answered by Anonymous · 0 1

fedest.com, questions and answers