实用说明:谁能举例说明POPS和OOPS之间的区别? [英] Practical Explanation : Can anyone Explain the difference between POPS and OOPS with Example?

查看:119
本文介绍了实用说明:谁能举例说明POPS和OOPS之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我访问了很多站点,了解了面向过程的程序设计和面向对象的程序设计之间的区别,但是我没有得到实际的回答.

I visited so many sites about the differences between Procedular Oriented Programming and Object Oriented Programming , but I did not get Practical answer .

每个人都在说理论答案.

Everyone is saying theoritical answer .

有人可以为此提供实用的解释吗?

Can anyone give Practical Explanation for this ?

推荐答案

过程编程是一列指令或一组指令,告诉计算机逐步执行的操作以及如何从第一个代码执行到第二个代码.

Procedural programming is a list or set of instructions telling a computer what to do step by step and how to perform from the first code to the second code.

过程语言的最好例子是C

the best example of a procedural language is C

例如,这是用于过程编程的python代码(任何没有oops的代码):

for e.g here is a python code for procedural programming (any code without oops):

x = int(input('enter a number: '))

def even_odd(x):
    if x%2 == 0:
        print('even')
    else:
        print('odd')

even_odd(x)

面向对象的编程是一种编程样式,它使用类和对象来包装您的代码和数据,从而有助于仅在一个地方使用较少的代码.

Object oriented programming is the style of programming which uses classes and objects to wrap your code and data which helps to use lesser code and at only one place.

每种现代语言都使用oop

every modern language uses oop

for e.g:

class test:
    # your code here along with variables and functions
    x = 'something' #some code
    def test_func(): # some function 
        #your function code here

obj = test()  #this is the object created for the above class which will be used to access the data inside a class

从理论上讲,作为一个真实的例子,我认为即使上帝也使用面向对象的编程,也许他首先创建了一个称为生物的父类,该类包含完全相同的属性,例如完全相同的两只眼睛,两只手,一只嘴等,然后他从同一父类继承了更多的子类,例如人,老虎,老鼠;)

theoretically, as a real world example I think that even god also uses object oriented programming, maybe he first created a parent class called living things which contains exact same properties like exact 2 eyes, 2 hands, one mouth etc, and then he inherited more subclasses like human being, tiger, rat from the same parent class ;)

这篇关于实用说明:谁能举例说明POPS和OOPS之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆