Hello
C++ is compatible with most other programming languages, but C is not.
I don't really get this. From what I've heard, ABI compability with other languages is better with C.
In C, need to declare all variables at the beginning of the function block
This is wrong since............1999 !
C only supports primitive and built-in data types. C++ on the other hand, supports user-defined data types as well
You can define your own type in C with struct, union or enum.
struct
union
enum
// Structures struct stud_id { char name[20]; int class; int roll_number; char address[30]; };
In C++, it is impossible to have a field named class because this a reserved keyword in C++.
class
C++ uses the new operator and free() for memory allocation and the delete operator for memory de-allocation.
Since C++11, we should use smart pointers as much as possible (hence avoiding directly calls to newand delete).
new
delete
If you are a beginner programmer, it's recommended to start with C. [...] In fact, C++ can be complicated and overwhelming for beginners.
I tend to strongly disagree :)
Everything (almost?) you can do in C can be done in C++. Learning C++ can be easier than C:
std::string
printf()
scanf()
std::cout
std::cin
Learn C if you really need C. Otherwise, learn C++.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello
I don't really get this. From what I've heard, ABI compability with other languages is better with C.
This is wrong since............1999 !
You can define your own type in C with
struct
,union
orenum
.In C++, it is impossible to have a field named
class
because this a reserved keyword in C++.Since C++11, we should use smart pointers as much as possible (hence avoiding directly calls to
new
anddelete
).I tend to strongly disagree :)
Everything (almost?) you can do in C can be done in C++. Learning C++ can be easier than C:
std::string
from C++ instead.printf()
andscanf()
are much more complicated to use thanstd::cout
andstd::cin
.Learn C if you really need C. Otherwise, learn C++.