02-03-2004, 12:50 PM
Zack, Nathan isn't always correct =P. Here is my arguement that C++ isnt just C + Classes:
- C does not have classes/objects! all code is in functions (subroutines).
- C structures can not have methods
- C I/O is based on library functions:
printf, scanf, fopen, fclose, fread, fwrite, ⦠while C++ uses io streams.
- C does not support any function overloading (you canât have 2 functions with the same name).
- C does not have new or delete, you use the messy malloc() and free() library functions to handle dynamic memory allocation/deallocation.
- C does not have reference variables
- Most of all C doesnt have the STL =P
And just for all the C fans out here ( that includes me =P) the best thing I love about C++ is the new() and delete() operators. Heres a self explanatory example:
p1 = new int; // using new
p1 = (int *)malloc (sizeof(int)); // using malloc
p2 = new employee; // using new
p2 = (struct employee *)malloc (sizeof(struct employee)); // using malloc
p3 = new int[30]; // using new
p3 = (int *)malloc(sizeof(int)*30); // using malloc
Hehe =P
- C does not have classes/objects! all code is in functions (subroutines).
- C structures can not have methods
- C I/O is based on library functions:
printf, scanf, fopen, fclose, fread, fwrite, ⦠while C++ uses io streams.
- C does not support any function overloading (you canât have 2 functions with the same name).
- C does not have new or delete, you use the messy malloc() and free() library functions to handle dynamic memory allocation/deallocation.
- C does not have reference variables
- Most of all C doesnt have the STL =P
And just for all the C fans out here ( that includes me =P) the best thing I love about C++ is the new() and delete() operators. Heres a self explanatory example:
p1 = new int; // using new
p1 = (int *)malloc (sizeof(int)); // using malloc
p2 = new employee; // using new
p2 = (struct employee *)malloc (sizeof(struct employee)); // using malloc
p3 = new int[30]; // using new
p3 = (int *)malloc(sizeof(int)*30); // using malloc
Hehe =P