C++ Semi OOP : Reason
C++ Semi OOP : Reason
What is Object Oriented Language?
The programming methodology to organize a complex program into simple programs by using concepts such as Abstraction, Encapsulation, Polymorphism, and inheritance are called object-oriented programming languages.
Why C++ is semi Object Oriented Language?
1. Main function is outside the class.
2. Friend function is present which can access private data of other class.
3. Global variables allowed.
we have elaborated above point below -
Case 1: Main Functions outside Class :
Semi Object Oriented: Live Example
#include<iostream.h>
Class Person
{
-------
-------
}
void main()
{
Person P1;
-------
-------
-------
-------
}
- Above C++ Code Snippet will start its execution from the main function.
- Inside Main Function we are going to create Object of the Class.
- Creation of Class/Object is optional while the creation of the main function is mandatory.
- We can say that C++ is also to C (structural) and C++ provides optional OOP features, thus we can say that it is semi object oriented.
Pour Object Orianted Program : Live Example
public class HelloWorldExample{
public static void main(String args[]){
System.out.println("Hello World !");
}
}
- It is Java Code which clearly shows that - We have to create Class.
- Still is tells us that main is going to execute first as it is Static.
Case 2 : Global Vriables :
1. In C++ can declare global variables that are accessible in all classes and have
life time equal to life time of entire program.
2. However in Java (Complete OOP) we have declare variables inside Class only,
We can use access specifier to make them accessible outside the class.
Advantages of Object Orianted Programming :-
1. Exploits the expressive power of all object orianted programming languages.
2. Encourages the resuse of software componentes.
3. Leades to the systems that are more resilients to change.
4. Reduces the development risk.
Features of Object Oriented Programming :-
1. More focus on data.
2. Bottom-up approch.
3. Abstraction
4. Encapsulation
5. Inheritannce
6. Polymorphism
0 comments:
Post a Comment