I am pretty good at C but in C++ I am not, Could you please help me to understand what are the top 3 main differences between them.Thank you.
I am pretty good at C but in C++ I am not, Could you please help me to understand what are the top 3 main differences between them.Thank you.
What is the major difference between C and C++ at DuckDuckGo
And no, you're not going to understand C++ just by knowing the differences (of which there are many).
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
You might as well think of them as two completely different development languages. Like you will usually find me doing.
o.O
Hi Pankaj,
I agree with Salem, If you are looking to learn C++ you cannot get anywhere just by knowing the differences. However in case you are just curious about knowing the differences, I can help state a few below.
The Key difference between C and C++ is that they are two different computer programming languages. C++ was developed from the C programming language; however they are quite different in nature. C is a procedure oriented language, whereas C++ supports both procedural and object oriented programming, therefore it is often called a hybrid language.
C provides calloc() and malloc() for dynamic memory allocation, and free() for memory deallocation. C++ provides the new operator for memory allocation and the delete operator for memory deallocation.
C supports procedural programming paradigms for code development. C++ is a hybrid language that supports both procedural and object-oriented models.
Since C does not support encapsulation, data and functions are separate and act as free entities. C++ supports encapsulation, so its data and functions are encapsulated together in the form of an object.
Check out <<<snipped>>> which talks about the differences between C and C++.
Last edited by Salem; 05-30-2022 at 10:34 AM. Reason: Removed spammed link
There is a chance that my familiarity with this subject does not qualify me to comment on this but.
C++ code implementing certain patterns compared to C code implementing the same pattern or even data structure will usually tend to be completely different. This has lead me to believe that these two languages should be treated as two completely different languages.
Let alone patterns, data structures
Speaking of which, is it not possible to implement encapsulation with C? Is this not what 'opaque' objects implement?
For creating a library, encapsulation can be simulated with header files that are part of the library source, but not part of the API. Users of the compiled library can't see or make use of any functions or structs in that hidden header file, but can be accessed and used by the API functions.