+ 2
What is the difference between procedure oriented langauge and oop???
I think...I m not sure... I want to decorate a room and if I m using Java then first I will make table,chair etc.then I will decorate.Now if I want to place chair first then table.only I will exchange them. NOW if I m using C.i will first make a chair and will place at the first place. then table and will place at second position.now if I want to change something.i have to start from starting.
3 Answers
+ 1
Your example is not completely inaccurate, however you can create tables and chairs ahead of time in C as well using functions.
The main difference between object oriented and procedural programming is the features provided by oops, which are
Object
Class
Data Hiding and Encapsulation
Dynamic Binding
Message Passing
Inheritance
Polymorphism
+ 1
i can only think of an example for inheritance right now.
suppose you are creating a game. You create an enemy class, you give it bounds like width, height, etc.
now when you create individual enemies, like ogres, thieves, monsters, etc. you just inherit the enemy class in them. This may not be clear as it is, but here's an example of a function.
let's create a function for detecting collision with the enemy.
if we create collision detection for ogre, we can use
detectCollision (Player p, Ogre o);
the same can be done for other enemies nd it becomes really tedious.
so you can simply create a single function
detectCollision (Player p, Enemy e);
since, all enemies are the child of enemy class, an object of these classes is also considered an object of the enemy class..
(sorry for such a complex answer. my main focus is on game development so I can't think of any other example)
0
OK... could you give me any real life example???