Why C++ is Semi Object Oriented Language ?
What is Object Oriented Language?
The programming methodology to organize 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?
- Main function is outside the class.
- Friend function is present which can access private data of other class.
- Global variables allowed.
we have elaborated above points below -
Case 1 : Main Function is 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 main funtion.
- Inside Main Function we are going to create Object of the Class.
- Creation of Class/Object is optional while the creation of main function is mandatory .
- We can say that C++ is close to C (structural) and C++ provides optional OOP features , thus we can say that it is semi object oriented.
Pure Object Oriented 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 it tells us that main is going to execute first as it is Static.
Case 2 : Global Variables
- In C++ we can declare global variables that are accessible in all classes and have life time equal to life time of entire program.
- However in Java (Complete OOP) we have to declare variables inside Class only , We can use access specifier to make them accessible outside the class.
Advantages of Object Oriented Programming :-
- Exploits the expressive power of all object oriented programming languages.
- Encourages the resuse of software components.
- Leads to the systems that are more resilient to change.
- Reduces the development risk.
Features of Object Oriented Programming :-
- More focus on data.
- Bottom-up approach.
- Abstraction
- Encapsulation
- Inheritance
- Polymorphism