28.7 Summary

I l @ ve RuBoard

What you must do to get C to compile with a C++ compiler:

  • Change K&R-style function headers into standard C++ headers.

  • Add prototypes .

  • Rename any functions or variables that are C++ keywords.

  • Change setjmp / longjmp calls into catch / throw operations.

Once you've done these tasks , you have a C+ 1 / 2 program. It works, but it's really a C program in C++'s clothing. To convert it to a real C++ program, you also need to do the following:

  • Change malloc to new .

  • Change free to delete or delete [] calls.

  • Turn printf and scanf calls into cout and cin .

  • When turning struct declarations into class variables, be careful of read , write , and memset functions that use the entire structure or class.

I l @ ve RuBoard


Practical C++ Programming
Practical C Programming, 3rd Edition
ISBN: 1565923065
EAN: 2147483647
Year: 2003
Pages: 364

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net