Difference between C and C++ - C Vs C++
S. No.
|
C
|
C++
|
1
|
C is a structural or procedural programming language.
|
C++ is an object oriented programming language.
|
2
|
Emphasis is on procedure or steps to solve any problem.
|
Emphasis is on objects rather than procedure.
|
3
|
Functions are the fundamental building blocks.
|
Objects are the fundamental building blocks.
|
4
|
In C, the data is not secured.
|
Data is hidden and can’t be accessed by external functions.
|
5
|
C follows top down approach.
|
C++ follows bottom up approach
|
6
|
C uses scanf() and printf() function for standard input and output.
|
C++ uses cin>> and cout<< for standard input and output.
|
7
|
Variables must be defined at the beginning in the function.
|
Variables can be defined anywhere in the function.
|
8
|
In C, namespace feature is absent.
|
In C++, namespace feature is present.
|
9
|
C is a middle level language.
|
C++ is a high level language.
|
10
|
Programs are divided into modules and functions.
|
Programs are divided into classes and functions.
|
11
|
C doesn't support exception handling directly. Can be done by using some other functions.
|
C++ supports exception handling. Done by using try and catch block.
|
12
|
Features like function overloading and operator overloading is not present.
|
C++ supports function overloading and operator overloading.
|
13
|
C program file is saved with .C extension.
|
C++ program file is saved with .CPP extension.
|
VIRTUAL FUNCTION
If there are member functions with same name in base class and derived class, virtual functions gives programmer capability to call member function of different class by a same function call depending upon different context. This feature in C++ programming is known as polymorphism which is one of the important feature of OOP.
If a base class and derived class has same function and if you write code to access that function using pointer of base class then, the function in the base class is executed even if, the object of derived class is referenced with that pointer variable.
Difference Between Procedure Oriented Programming (POP) & Object Oriented Programming (OOP)
| Procedure Oriented Programming | Object Oriented Programming | |
|---|---|---|
| Divided Into | In POP, program is divided into small parts called functions. | In OOP, program is divided into parts called objects. |
| Importance | In POP,Importance is not given to data but to functions as well as sequence of actions to be done. | In OOP, Importance is given to the data rather than procedures or functions because it works as a real world. |
| Approach | POP follows Top Down approach. | OOP follows Bottom Up approach. |
| Access Specifiers | POP does not have any access specifier. | OOP has access specifiers named Public, Private, Protected, etc. |
| Data Moving | In POP, Data can move freely from function to function in the system. | In OOP, objects can move and communicate with each other through member functions. |
| Expansion | To add new data and function in POP is not so easy. | OOP provides an easy way to add new data and function. |
| Data Access | In POP, Most function uses Global data for sharing that can be accessed freely from function to function in the system. | In OOP, data can not move easily from function to function,it can be kept public or private so we can control the access of data. |
| Data Hiding | POP does not have any proper way for hiding data so it is less secure. | OOP provides Data Hiding so provides more security. |
| Overloading | In POP, Overloading is not possible. | In OOP, overloading is possible in the form of Function Overloading and Operator Overloading. |
| Examples | Example of POP are : C, VB, FORTRAN, Pascal. | Example of OOP are : C++, JAVA, VB.NET, C#.NET. |
0 comments:
Post a Comment