As someone who switches between C++ and C and besides classes and inheriting what’s the actual difference between native C++ and C? Never really explored beyond Unreals macro heavy version of C++, wxwidgets and QT
C++ is technically a completely different programming language to C, but they share a lot of similarities because C++ is sort of derived from C (and now they’ve both evolved somewhat separately). The main addition at the start was OOP being baked in to C++. A typical C program is often a valid C++ program as well, but there are some subtle differences in a few areas that can cause problems. C++ has a lot of features compared to C, a more complex type system, a big templating system for compile-time computation, and focuses a lot on adding low/no cost abstractions to make writing programs easier without incurring a high cost at run-time… That said many people do still prefer C, often for its simplicity in comparison.
C++ is a superset of C, and C is a subset of C++. C++ was originally designed for the purpose of updating and adding OOP to C.
The main things C++ has that C doesn’t are user defined data types, support of reference variables, function overloading/overriding, built in exception handling with try/catch, inline functions, and C++ has around 30 more keywords overall.
I would say the biggest difference is the OOP focus of C++ where all of data and functions are encapsulated into an object. This helps make C++ more secure and better for writing high level implementations than C.
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
Posts must be relevant to programming, programmers, or computer science.
No NSFW content.
Jokes must be in good taste. No hate speech, bigotry, etc.
As someone who switches between C++ and C and besides classes and inheriting what’s the actual difference between native C++ and C? Never really explored beyond Unreals macro heavy version of C++, wxwidgets and QT
C++ is technically a completely different programming language to C, but they share a lot of similarities because C++ is sort of derived from C (and now they’ve both evolved somewhat separately). The main addition at the start was OOP being baked in to C++. A typical C program is often a valid C++ program as well, but there are some subtle differences in a few areas that can cause problems. C++ has a lot of features compared to C, a more complex type system, a big templating system for compile-time computation, and focuses a lot on adding low/no cost abstractions to make writing programs easier without incurring a high cost at run-time… That said many people do still prefer C, often for its simplicity in comparison.
C++ is a superset of C, and C is a subset of C++. C++ was originally designed for the purpose of updating and adding OOP to C.
The main things C++ has that C doesn’t are user defined data types, support of reference variables, function overloading/overriding, built in exception handling with try/catch, inline functions, and C++ has around 30 more keywords overall.
I would say the biggest difference is the OOP focus of C++ where all of data and functions are encapsulated into an object. This helps make C++ more secure and better for writing high level implementations than C.
And namespaces! And strongly typed enumerators! And templates! And type deduction! And…!
Ahh so the whole create a object from a class thing actually works in native C++. So I can create child classes aswel and do cool stuff like casting.
Don’t laugh okay I thought C++ through Unreal Engine was vastly different from native C++ (because that’s what I learnt first)
Never actually used classes when I was playing with native C++. Couldn’t think of anything simple to make that would require it