漠丶涯

What is the OBJECT of C++

How to understand the object of C++.

1.OBJECT IS  VARIABLE IN PROGRAMMING LANGUAGES.(like data type:  int a  ,  is  also an object)

2.OBJECT = ATTRIBUTES +  SERVICES

Data:the properties or status  ,

Operations : the functions

3. MAPPING : From the problem space to the solution one.

exp 1: C doesn't support relationship between data and function.

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);

exp2: C++ VERSION 

CLASS POINT3D {

public:

point3d(float x, float y,float z);

print();

private:

float x;

float y;

float z;

};

point3d a(1,2,3);

a.print();

What is object oriented

A way to organize;

designs,

Implementations

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

To focus on things , not operations.

评论