answersLogoWhite

0


Best Answer

The similar features of C and C++ is C itself. C++ is a superset of C, thus every C program is (or can be) a valid C++ program. C++ is more consistent and stricter than C, however, so some C programs may need some minor alterations in order to become C++ compliant. For that reason it is simpler to enumerate the differences than it is to enumerate the similarities.

The following list enumerates all the differences with respect to a C programmer compiling C code under C++.

1. In C++, assigning from void* is not permitted -- you must use an explicit cast.

int *x = malloc (sizeof (int) * 10); // C version

int *x = static_cast<int*>( malloc (sizeof (int) * 10)); // C++ version

2. In C++, a function MUST be declared before it can be used. Although most C programs do follow this convention, it is not strictly enforced.

3. In C++, we cannot invoke the main function from within another function of the same program.

4. In C++, main must return an int, however return 0 is implied if not explicitly stated at the end of the function.

5. In C++, multiple declaration of global variables is not permitted.

Provided a C programmer adheres to these conventions, the program will compile under C++. Everything else in C is fully compliant with C++.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Similar features of c and c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Do I need features of c plus plus?

No.


What is the difference between cc plus plus and c sharp?

C# is inherited from c++ with some additional features


What are the features of C plus plus that surpass C?

Object-oriented programming and stricter type-safety.


What are the features in java that makes it similar to C programming?

Java is not similar to C. Java is, however, similar to C++. Both C++ and Java are object orientated programming languages (OOPL's).


What are the main features of OOP in c plus plus?

The main features of OOP are the same regardless of the language. They are: encapsulation; data hiding; inheritance; and polymorphism.


Is g plus plus similar to c plus plus?

G++ is the Gnu compiler's extension for C++. It is not a different language. It simply allows you to use the GCC compiler to write C++ code.


What are the most prominent features of C plus plus?

Object oriented programming. General purpose. Cross-platform.


Does C plus plus compiler will compile C in programming?

Yes we can compile a c program using c++ compiler. Because c++ evolved from the c. c++ have some additional features beyond c. c++ support almost all concepts used in c.


Is it important to have c plus plus for computer engineering?

Yes, because C++ is a very popular language, and many systems are written in C, C++, or Java. (C is the predecessor of C++, and Java is similar to C++ in many ways.)


How Java and C plus plus are similar?

Java and C++ are similar because Java is based upon C++ insofar as they both have a very similar language and syntax. The similarity ends there, however. Java has a much simpler object model and is highly abstract, and therefore provides no low-level architecture routines. Code is compiled as byte code suitable for the Java virtual machine which, although highly-portable, adds an extra layer of abstraction that you don't get with C++, which compiles to native machine code with virtually unrestricted access to the low-level architecture and its features.


Why java and c plus plus keep together?

If I understand your question, they are similar because one language came from the other.


Is it safe to uninstall Microsoft visual c plus plus?

Yes, it is. Just make sure that you it though "Programs and Features" (Windows 7).