I have read in tutorials that C++ contains the entire C programming language.
However I have also read, in places like this that
If you learn C++ you will eventually learn most of C with some differences between the languages that you will learn over time.
So my question is only this:
If I know C++ very well, will I eventually learn the "real" C language (without any "differences") because the full C90 language is included in C++11?
Additional Features: As C++ is an extension of the C programming language, so it contains all the features of C, such as portability, rich library, structured programming, pointer, memory management, etc.
C language allows multiple declarations of global variables. C++, however, doesn't allow multiple declarations of global variables. #15) Pointers And Reference Variables: Pointers are the variables that point to memory addresses. Both C and C++ support pointers and various operations performed on pointers.
While C and C++ may sound similar, their features and usage differ. C is a procedural programming language that support objects and classes. On the other hand C++ is an enhanced version of C programming with object-oriented programming support.
C is one of the earliest and most widely used programming languages. C is the fourth most popular programming language in the world as of January 2022. Modern languages such as Go, Swift, Scala, and Python are not as popular as C. Where is C used today?
No, C++ is not a superset of the C language. While C++ contains a large part of C, there are subtle difference that can bite you badly where you least expect them. Here are some examples:
void
pointers to variables of concrete type.const
propagation.int
rule,” which, although abolished with C99, appears some times and needs to be considered.a ? b : c = d
is a syntax error in C but parsed as a ? b : (c = d)
in C++.&*E
is exactly identical to E
, even if E
is a null pointer. C++ has no such guarantee.\0
byte. (i.e. char foo[3] = "bar"
is legal). In C++, the array has to be at least as long as the string including the trailing \0
byte.'A'
has type int
. In C++, it has type char
.C has a special rule to make type punning through unions to be legal. C++ lacks this language, making code such as
union intfloat {
int i;
float f;
} fi;
fi.f = 1.0;
printf("%d\n", fi.i);
undefined behaviour.
If I know C++ very well, will I eventually learn the "real" C language (without any "differences")
If you learn C++ properly, you will probably not need to use many of the standard techniques used in C. Theoretically you could program almost anything C in C++, with exceptions that have already been introduced. However, in reality, you wouldn't - or shouldn't. This is because C++ is a different language that provides a very different set of tools when used optimally.
Aside from the very basic elements like general syntax and fundamental types, these are two separately evolving languages, and they should be approached (learned, programmed) as such.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With