I was wondering what are the differences between C and C++? I'm wondering because of the fact that I can follow along most C code and understand it. I know classes are new (and recently, namespace std) but what else?
I was wondering what are the differences between C and C++? I'm wondering because of the fact that I can follow along most C code and understand it. I know classes are new (and recently, namespace std) but what else?
The STL, all kinds of little additions, I think new and delete are new to C++ or do they work in C?
Using Dev-C++ on Windows
new and delete as well as new[] and delete[] are specific for C++ and will not work in C, though malloc() and free() which are the equivalent in C (and are probably hidden somewhere in new and delete) will work in C++.
Structs in C++ work differently than in C. Inheritance and polymorphism are offshoots of classes and therefore not available in C.
You're only born perfect.
C++ has templates.
They are very different from a design aspect. C focuses on procedural programming, while C++ focuses on object oriented and generic programming.
On a side note, C++ is not a superset of C.
The superset of C is "C with classes".
Structs are used differently (calling methods, ie you have to type struct before you create an object of a struct type)
Another thing C++ has is operator overloading
c
Code:malloc( ) printf( ) sprintf( ) fgets( ) char[ ] free int number = (int)'A' ;
c++
Code:new cout << cin >> string delete int number = static_cast<int>('A'); class { }; struct{ };
Last edited by The Brain; 07-25-2005 at 09:08 PM.
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
Why would you typecast a char into a char before assigning to an int??Originally Posted by The Brain
oh my bad.. i'll edit
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
http://david.tribble.com/text/cdiffs.htmOriginally Posted by blankstare77
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
One is good and well the other is good .
Woop?