C Vs C++:Comparision

by rajeevIITDelhi in Teachers > University+

55 Views, 0 Favorites, 0 Comments

C Vs C++:Comparision

1.png

C vs C++

C++ extension of C that comes with tonnes of added features. Here we see a birds' eye view comparing both.


Few Words

I have been programming in C language for over a decade. And no doubt it is straightforward to me irrespective of the platform where I used it. Recently I was brushing up on my C++ skills, pronounced as C plus plus, I thought it is good to write an article comparing both. Even though you can find dozens of articles on the internet comparing them but I would be very honest saying a word on feature or loophole.

Simplicity

2.png

As said above C language is very simple compared to C++. Yes C++ is complicated and sometimes it would tear you down. For example 'abstract class and virtual function' comes tricky and can really tear you down. So, as far as simplicity is concerned C is simple to learn and use keep my word.

OOPS-Object Oriented Programming

4.png

C is a procedural-based language while C++ is an object-oriented programming language. It is here enhancement occurred providing an all-new paradigm of object-oriented programming. This allows the data hiding concept by binding it with the member function and restricting the use of data and member function by any other.

A clever person over the internet can confuse you on OOPS features selling C++ over C. But that's not true. Yes, it is very enhanced and rich in features compared to see but it does not make it to take over C language. Both have their space in the programming ecosystem.

Class: A class in c++ is like a structure in C++ that have variables and data members or member functions.

Object: An Object is an identifiable entity with some characteristics and behavior. An Object is an instance of a Class.

Encapsulation: Encapsulation is the binding of data variables and member functions to work together. This creates a different independent block whose data can only be accessed through the object of that class.

Inheritance: In this feature, we can derive a class from another class. For example, let us say we have a class with 100 lines of code we derive a child class of it and get 100 lines of code without writing them again. Inheritance can be of different types like single level, multilevel, multiple, and hybrid.

Polymorphism: Poly means many, so we can use the same name function more than one time, unlike C, by changing the number of arguments or order of arguments. This is also called function overloading. This is not possible in C.

Abstraction: Abstraction means showing only essential information while hiding the process working behind it. This can be achieved in different methods like using abstract classes, and data specifiers, like the member, declared public can be accessed anywhere while private ones are restricted to access from any part of the program.

Exception Handling

Exception handling is the handling of errors generated while executing the program. This feature is not available in C language. Conditions responsible for creating errors during the execution are called Exception handling. This is achieved using try, throw and catch blocks. This helps identify the specific problem while executing and debugging it.

Which One to Learn First?

It is an obvious reason you should go for C first as per my experience however it is your or application demand you would like to go with the specific one. For example, if you are developing software like 'Microsoft Word' , which has been written in C++, you would leave with no other option but to go with C++. But still, I would recommend learning C first and C++ later.

How to Learn?

YouTube is flooded with number of tutorials you can refer to. Another choice is to enroll in an online platform like Coursera, udemy.

I would suggest you to use a book as a referral in parallel. I used 'Let Us C for C and Let Us C++ for C++ by Yashwant Kanetkar. There are more books to see and learn, check online.

The Bottom Line

Expertise in C before you move to C++.

Exploit OOPS concept for your application.