hm..so many debates about C and C++, so I'd put some of thoughts in.
Basic of C:
#include // how you include files#define // how you define things or "constants"int main() // how you write your main function / bodyreturn // it'a about ending a functionfor ( ; ; ) // for loopswitch () // switch caseif () else // if then else statementsvoid myfunction() // writing your own functionint myvar // writing your own variablesstruct mystruct // writing your own structenum myenum // writing your own enumeration+,-,*,/ // your first arithmetic+=, -=, *=, /= // a more advanced use of arithmetic>>, << // binary shift!<<=, >>= // a more advanced use of binary shiftint *pointer // yuck, it's a pointer!malloc, free // dynamic memory allocation
Basics of C++:
cout << "hello world" // using cout..again, *using* cout, with a binary shift operator? i wonder how do you binary shift a string...class myclass // how you write your own classpublic,protected.. // security thingiesconst // the true constant finally here!& // hm..reference...new delete // dynamic memory allocation, C++ style.
now, what you see in a typical C++ tutorial..or I must say, the C++ "Hello World":
#include <iostream.h>
int main()
{
cout << "Hello World" << endl;
return 0;
}
how many C basics that you see compared to C++ basics in that piece of code? Roughly, 3:1. Conclusion? Learn C first. Go C++ after you grasp the basic. If you go straight C++, you kill yourself. Why? There is no way you can create a useful class without knowing how to write a function or variable (which is in C). So, why do people suggest to learn C++ instead of C? Because they think writing a variable is part of C++ basic. When you read a C++ book/tutorial..then the author tells you how to write a variable...he's teaching you C, not C++.
EDIT: some spelling errors
[edited by - alnite on November 9, 2002 12:24:57 AM]