Using C Keywords in C++ [closed]
-
23-12-2019 - |
Question
So I was wondering why C++ allows for C keywords to be used. After all, printf("Hello, World!\n");
does the same thing as cout << "Hello, World!\n";
. Is one returned to the processsor faster than the other? Or are there some keywords in C that you may need in C++? (P.S: This question is out of sheer curiosity)
Solution
This is because C++ was designed to allow for as much compatability with C code as possible. It allows it to be more extensible, and easily adopted into applications previously written in pure C.
OTHER TIPS
C++ wasn't envisioned as a separate language from C; it grew out of "C with Classes". Every further revision to C++ maintained backward compatibility whenever it was reasonably practical. It's not particularly impractical to keep the C standard library around, so there it is.
Because C++ was supposed to be backward compatible with C.
They're not keywords; they're function and class names from the Standard Library.
The C library (with a few modifications) is available as part of the C++ library; so you can call C library functions like printf
from a C++ program if you want.