2-1什么是面向对象

本文探讨了对象的概念,指出对象可以是可见或不可见的,并且是编程语言中的变量,由属性和服务组成。在C语言中,数据和函数没有直接关联,而C++引入了类,使得数据和函数能够封装在一起。对象导向编程是一种设计和实现方式,其焦点在于对象而非控制或数据流,强调关注事物本身而非操作。通过C和C++的例子,展示了对象如何从问题空间映射到解决方案空间。
摘要由CSDN通过智能技术生成

What is object? 

object=entity

object may be

        visible

        invisible

Object is variable in programming language.


Object=attributes+services

Data:the properties or status

Operation:the functions


Mapping

From the problem space to the solution one. ​​​​​​​


 C vs. C++

C doesn't support relationship btw data and functions. 

typedef struct point3d{
    float x;
    float y;
    float z;
}Point3d;

void Point3d_print(const Point3d* pd);

Point3d a;
a.x=1;a.y=2;a.z=3;
Point3d_print(&a);

C++ 

class Point3d{
public:
    Point3d(float x,float float z);
    print(); 
private:
    float x;
    float y;
    float z;
};

Point3d a(1,2,3);
a.print();

What is object-oriented? 

A way to organiaze

        Designs

        Implementations

Object, not control or data flow, are the primary focus of the design and implementation. 

To focus on things, not operations. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值