C++ is an object oriented programming language which supports all the features provided by object oriented methodology. C++ was developed in AT & T Bell laboratory in early 1980â€™s by Bjarne Stroustrup. Initially C++ was named C with classes. Later itâ€™s name changed to C++. The idea of C++ comes from Câ€™s increment operator ++. All C programs are C++ programs that is all C programs can run within C++ environment.
C is as it is in C++ but additional C does not have security but C++ have.
|No.||C Language||C++ Language|
|1)||C is Procedural Language.||C++ is non Procedural i.e Object oriented Language.|
|2)||No virtual Functions are present in C||The concept of virtual Functions are used in C++.|
|3)||In C, Polymorphism is not possible.||The concept of polymorphism is used in C++.|
|4)||Operator overloading is not possible in C.||Operator overloading is one of the greatest Feature of C++.|
|5)||Top down approach is used in Program Design.||Bottom up approach adopted in Program Design.|
|6)||No namespace Feature is present in C Language.||Namespace Feature is present in C++ for avoiding Name collision.|
|7)||Multiple Declarations of global variables are allowed.||Multiple Declarations of global variables are not allowed.|
â€¢ scanf() Function used for Input.
â€¢ printf() Function used for output.
â€¢ Cin>> Function used for Input.
â€¢ Cout<< Function used for output.
|9)||Mapping between Data and Function is difficult and complicated.||Mapping between Data and Function can be used using "Objects"|
|10)||In C, we can call main() Function through other Functions||In C++, we cannot call main() Function through other functions.|
|11)||C requires all the variables to be defined at the starting of a scope.||C++ allows the declaration of variable anywhere in the scope i.e at time of its First use.|
|12)||No inheritance is possible in C.||Inheritance is possible in C++|
|13)||In C, malloc() and calloc() Functions are used for Memory Allocation and free() function for memory deallocating.||In C++, new and delete operators are used for memory allocating and deallocating.|
|14)||It supports built-in and primitive data types||It support both built-in and user define data types|
|15)||In C, Exception Handling is not present.||In C++, Exception Handling is done with Try and Catch block.|
Objects are the basic unit of OOP. They are instances of class, which have data members and use various member functions to perform tasks.
It is similar to structures in C language. Class can also be defined as user defined data type but it also contains functions in it. So, class is basically a blueprint for object. It declares & defines what data variables the object will have and what operations can be performed on the class's object.
Abstraction refers to showing only the essential features of the application and hiding the details. In C++, classes provide methods to the outside world to access & use the data variables, but the variables are hidden from direct access. This can be done access specifiers.
It can also be said data binding. Encapsulation is all about binding the data variables and functions together in class.
Inheritance is a way to reuse once written code again and again. The class which is inherited is called base calls & the class which inherits is called derived class. So when, a derived class inherits a base class, the derived class can use all the functions which are defined in base class, hence making code reusable.
It is a feature, which lets us create functions with same name but different arguments, which will perform differently. That is function with same name, functioning in different way. Or, it also allows us to redefine a function to provide its new definition. You will learn how to do this in details soon in coming lessons.
Exception handling is a feature of OOP, to handle unresolved exceptions or errors produced at runtime.
Message Passing is nothing but sending and receiving of information by the objects same as people exchange information. So this helps in building systems that simulate real life. Following are the basic steps in message passing.
â€¢Creating classes that define objects and its behavior.
â€¢Creating objects from class definitions.
â€¢Establishing communication among objects.
In OOPs, Message Passing involves specifying the name of objects, the name of the function, and the information to be sent.
Dynamic Binding refers to linking a procedure call to the code that will be executed only at run time. The code associated with the procedure in not known until the program is executed, which is also known as late binding.