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.