Object oriented programming - class design confusion

前端 未结 13 1754
你的背包
你的背包 2021-02-05 22:01

I am trying to wrap my head around object oriented programming.

My understanding is that we have objects so we can design our programs to mirror real-life objects.

13条回答
  •  执笔经年
    2021-02-05 22:44

    Should a fruit object rather be passed to a human object which has a Eat() function?

    Yes.

    But program objects are generally more abstract than this naive example. In the real world of computer programming, objects like fruit and humans would generally be represented as attributes in a database. The consumption and manipulation of such data would be done in programming objects.

提交回复
热议问题