No. | C | C++ |
---|---|---|
1) | C follows the procedural style programming. | C++ is multi-paradigm. It supports both procedural and object oriented. |
2) | Data is less secured in C. | In C++, you can use modifiers for class members to make it inaccessible for outside users. |
3) | C follows the top-down approach. | C++ follows the bottom-up approach. |
4) | C does not support function overloading. | C++ supports function overloading. |
5) | In C, you can't use functions in structure. | In C++, you can use functions in structure. |
6) | C does not support reference variables. | C++ supports reference variables. |
7) | In C, scanf() and printf() are mainly used for input/output. | C++ mainly uses stream cin and cout to perform input and output operations. |
8) | Operator overloading is not possible in C. | Operator overloading is possible in C++. |
9) | C programs are divided into procedures and modules | C++ programs are divided into functions and classes. |
10) | C does not provide the feature of namespace. | C++ supports the feature of namespace. |
11) | Exception handling is not easy in C. It has to perform using other functions. | C++ provides exception handling using Try and Catch block. |
Comparison Index | C++ | Java |
---|---|---|
Platform-independent | C++ is platform-dependent. | Java is platform-independent. |
Mainly used for | C++ is mainly used for system programming. | Java is mainly used for application programming. It is widely used in window, web-based, enterprise and mobile applications. |
Goto | C++ supports goto statement. | Java doesn't support goto statement. |
Multiple inheritance | C++ supports multiple inheritance. | Java doesn't support multiple inheritance through class. It can be achieved by interfaces in java. |
Operator Overloading | C++ supports operator overloading. | Java doesn't support operator overloading. |
Pointers | C++ supports pointers. You can write pointer program in C++. | Java supports pointer internally. But you can't write the pointer program in java. It means java has restricted pointer support in java. |
Compiler and Interpreter | C++ uses compiler only. | Java uses compiler and interpreter both. |
Call by Value and Call by reference | C++ supports both call by value and call by reference. | Java supports call by value only. There is no call by reference in java. |
Structure and Union | C++ supports structures and unions. | Java doesn't support structures and unions. |
Thread Support | C++ doesn't have built-in support for threads. It relies on third-party libraries for thread support. | Java has built-in thread support. |
Documentation comment | C++ doesn't support documentation comment. | Java supports documentation comment (/** ... */) to create documentation for java source code. |
Virtual Keyword | C++ supports virtual keyword so that we can decide whether or not override a function. | Java has no virtual keyword. We can override all non-static methods by default. In other words, non-static methods are virtual by default. |
unsigned right shift >>> | C++ doesn't support >>> operator. | Java supports unsigned right shift >>> operator that fills zero at the top for the negative numbers. For positive numbers, it works same like >> operator. |
Inheritance Tree | C++ creates a new inheritance tree always. | Java uses single inheritance tree always because all classes are the child of Object class in java. Object class is the root of inheritance tree in java. |
No. | Java | C# |
---|---|---|
1) | Java is a high level, robust, secured and object-oriented programming language developed by Oracle. | C# is an object-oriented programming language developed by Microsoft that runs on .Net Framework. |
2) | Java programming language is designed to be run on a Java platform, by the help of Java Runtime Environment (JRE). | C# programming language is designed to be run on the Common Language Runtime (CLR). |
3) | Java type safety is safe. | C# type safety is unsafe. |
4) | In java, built-in data types that are passed by value are called primitive types. | In C#, built-in data types that are passed by value are called simple types. |
5) | Arrays in Java are direct specialization of Object. | Arrays in C# are specialization of System. |
6) | Java does not support conditional compilation. | C# supports conditional compilation using preprocessor directives. |
7) | Java doesn't support goto statement. | C# supports goto statement. |
8) | Java doesn't support structures and unions. | C# supports structures and unions. |
9) | Java supports checked exception and unchecked exception. | C# supports unchecked exception. |
10) | Java code can never use pointers. | C# code can use pointers in unsafe mode. |
11) | Java is used on all platforms. | C# is used rarely outside Windows. |
12) | Java is Free and Open-Source. | C# is not Open-Source. |