The combined usage of C and C++ in a program system is subject to the following restrictions:
Free store management
The
new
anddelete
operators in C++ provide a separate facility for free store management. Storage space management in C, by contrast, is achieved by the functionsmalloc
andfree
. These two methods must not be combined.The effect of using
delete
to free storage that was requested withmalloc
(or usingfree
on storage that was requested withnew
) is undefined.Standard I/O files
C++ offers a new interface for file processing. The C++ standard files
cin
,cout
,cerr
andclog
correspond to the standard I/O filesstdin
,stdout
andstderr
in C.Note that if the corresponding standard files are used in both C and C++, the behavior of the program cannot be guaranteed.
If the standard I/O files for C and C++ are to be used in combination in the same C++ program, the C++ function
ios::sync_with_stdio()
must be called (see the manual “C++ Library Functions” [5]).