Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Except OOP, why is C++ better than C? [closed]

Tags:

c++

c

Well that may sound like a troll question, but since C++ seems hard to fully master (and I never really knew STL was actually "part" of it), I wanted to know what are the disadvantages to use C instead of C++ when not relying much on OOP.

C++ can have a very much sophisticated syntax sometimes, which is kinda confusing me while trying to use OGRE3D for example...

like image 806
gokoon Avatar asked Jun 27 '10 14:06

gokoon


People also ask

Why would you choose C rather than C++?

Other Reasons To Use C This makes the coding structure much more organized and easier to follow. Compared to C++, C is the simpler and ultimately faster programming language. C is procedural and does not support classes and objects, meaning it has less functionality than C++.

Why is C still best?

It is fast The programs that you write in C compile and execute much faster than those written in other languages. This is because it does not have garbage collection and other such additional processing overheads. Hence, the language is faster as compared to most other programming languages.

Why is C++ better than C?

C++ is a more object-oriented high-level programming language which requires fixed construction and principles. However, it is easier to code. C programming language does not adhere to the encapsulation concept and allows easy data manipulation from outside code. C++ is a more secure programming language.

Why is C used when there is C++?

The biggest practical reason for preferring C is that support is more widespread than C++. There are many platforms, particularly embedded ones, that do not even have C++ compilers. There is also the matter of compatibility for vendors.


1 Answers

Non-OO features that C++ has that C does not:

  1. Templates
  2. Function overloading
  3. References
  4. Namespaces
  5. You can use structs and enums without writing struct or enum before every declaration or using typedefs.
  6. Even if you don't define your own classes, using C++'s string and container classes is still often more convenient and safe to work with than c-style strings and arrays.
  7. Type safety (even though some would call it weak)
  8. Exceptions
  9. Variable declarations in conditionals, C99 only has it in for
like image 50
7 revs, 4 users 69% Avatar answered Oct 14 '22 08:10

7 revs, 4 users 69%