Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What are the differences between C and CPP?
What are the differences between C and CPP?
✍: Guest
Q: Is C++ a superset of C? What are the differences between C and C++? Can I use a C++ compiler to compile C code?
A: C++ was derived from C, and is largely based on it, but there are some legal C constructs which are not legal C++. Conversely, ANSI C inherited several features from C++, including prototypes and const, so neither language is really a subset or superset of the other; the two also define the meaning of some common constructs differently.
The most important feature of C++ not found in C is of course the extended structure known as a class which along with operator overloading makes object-oriented programming convenient. There are several other differences and new features: variables may be declared anywhere in a block; const variables may be true compile-time constants; structure tags are implicitly typedeffed; an & in a parameter declaration requests pass by reference; and the new and delete operators, along with per-object constructors and destructors, simplify dynamic data structure management. There are a host of mechanisms tied up with classes and object-oriented programming: inheritance, friends, virtual functions, templates, etc. (This list of C++ features is not intended to be complete; C++ programmers will notice many omissions.)
Some features of C which keep it from being a strict subset of C++ (that is, which keep C programs from necessarily being acceptable to C++ compilers) are that main may be called recursively, character constants are of type int, prototypes are not required, and void * implicitly converts to other pointer types. Also, every keyword in C++ which is not a keyword in C is available in C as an identifier; C programs which use words like class and friend as ordinary identifiers will be rejected by C++ compilers.
In spite of the differences, many C programs will compile correctly in a C++ environment, and many recent compilers offer both C and C++ compilation modes. (But it's usually a bad idea to compile straight C code as if it were C++; the languages are different enough that you'll generally get poor results.)
2015-01-10, 1145👍, 0💬
Popular Posts:
Can you explain in brief how the ASP.NET authentication process works? ASP.NET does not run by itsel...
How was XML handled during COM times? During COM it was done by using MSXML 4.0. So old languages li...
If XML does not have closing tag will it work? No, every tag in XML which is opened should have a cl...
If we have two version of same assembly in GAC how do we make a choice ? OK first let’s try to under...
What are the different elements in Functions points? The different elements in function points are a...