Difference Between C# and C++

CsharpC++Server Side ProgrammingProgramming

Let us first learn about C# and C++ −

  • C# is a general-purpose object-oriented programming language.
  • It is considered as a pure object-oriented programming language.
  • It is pronounced as 'C sharp'.
  • It was developed by Anders Hejlsberg and his team at Microsoft.
  • Memory Management is done automatically by the garbage collector.
  • It is the language's duty to automatically delete the object once its objective is completed.
  • It is windows specific, i.e. it can't be used on all systems.
  • It doesn't support multiple inheritance.
  • The pointers in C# can only be used in the unsafe mode.
  • It is considered as a high-level language.
  • Once the code is compiled, it gets converted into an intermediate language.
  • It can be used to develop console applications as well as mobile and windows applications.
  • It is easy to understand and work with, since it has a well-defined class hierarchy.
  • Bound checking in an array data structure is performed by a compiler.
  • Due to this, when a programmer tries to access an invalid array index, it results in a compilation error.

C++

  • C++ is a statically typed, multi-paradigm language.
  • It is also an object-oriented programming language.
  • But it is not a purely object-oriented programming language since it has certain primitive data types.
  • After the code is compiled, it gets converted into machine code, i.e low level language directly.
  • Initially, it was known as C with classes. Later, it was changed to C++.
  • It is pronounced as 'C plus plus'.
  • It was developed by Bjarne Stroustrup at AT & T Bell Laboratories.
  • Memory management in C++ is done manually by the programmer/developer. They create an object, and are totally responsible in using them and destroying them once its use is over.
  • Platform Dependency: Code in C++ can be run on any platform.
  • It is used where the application needs to interact with hardware directly.
  • Multiple inheritance: C++ supports multiple inheritance with the help of classes. This means that once class can extend to more than one class at a point in time.
  • C++ pointers can be used anywhere within the program.
  • It is generally used to develop console applications.
  • Bound checking is not done by compiler. When a programmer tries to access an invalid array index, it wouldn't result in a compilation error, it would just show the wrong output.

Let us now see the differences −

C#C++
C# is a general-purpose object-oriented programming language.C++ is a statically typed, multi-paradigm language.

It is considered as a pure object-oriented programming language.But it is not a purely object-oriented programming language since it has certain primitive data types.
Memory management is done automatically by the garbage collector.Memory management is done automatically by the garbage collector.
It doesn't support multiple inheritance.C++ supports multiple inheritance with the help of classes. This means that once class can extend to more than one class at a point in time.
The pointers in C# can only be used in the unsafe mode.C++ pointers can be used anywhere within the program.
It can be used to develop console applications as well as mobile and windows applications.It is generally used to develop console applications.
Bound checking in an array data structure is performed by a compiler.Bound checking is not done by compiler. When a programmer tries to access an invalid array index, it wouldn't result in a compilation error, it would just show the wrong output.
raja
Published on 02-Mar-2021 04:52:45
Advertisements