C VS C++ VS JAVA: - C Programming Tutorial
C VS C++
The main difference between C & C++ is the OOPS (Object Oriented Programming) concept in C++.
This makes C++ much more efficient than C Language. C is procedure oriented language and c++ is object oriented language. But basically it depends on the project to project which language to choose from C or C++.
C language's syntax is very easy as compared to C++.Another Difference is that C uses Top Down approach and focuses on procedures.
In it Data moves as such whereas in C++ uses the bottom up approach and focuses basically on data . There is Data Hiding what we call as data abstraction.
Dynamic memory allocation in C is by calloc() and in C++ by malloc() by new and delete respectively. In C we only able to declare the variable in global declaration part, but in C++ it is possible to declare a variable in anywhere in the program.
This is a big advantage of C++ over C because it saves our time while coding. Function prototyping is optional in c whereas it is compulsion in c++.
Sample Syntax for C & C++
In C, we cannot use template and template class. C source code file name should be *.c and *.h for implement file and header file.
Class is not supported in C, so you should convert all of class definition in C++ to structures and functions in C. C++ supports inheritance, polymorphism & encapsulation & C doesn't.
Access specifier in C is public, whereas in C++ it is private. C++ has more keywords than C.
C++ VS JAVA
On the Other hand, Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform.
It has no preprocessor.
If you want to use classes in another library, we have to import with name of the library.
There are no preprocessor-like macros.
Java uses packages in place of namespaces.
There are no Java pointers like in the C and C++.
There are no destructors in Java. Java has constructors, similar to constructors in C++.
Java has method overloading that works similar to C++ function overloading.
Java does not support default arguments.
There’s no goto in Java. Java has no templates.
Inheritance in Java is similar as in C++, but the syntax is different.
COPYRIGHT 2009 ALL RIGHTS RESERVED FREECPROGRAMS.COM