May 1996
Intermediate to advanced
304 pages
5h 54m
English
In C, a data abstraction and the operations that perform on it are declared separately—that is, there is no language-supported relationship between data and functions. We speak of this method of programming as procedural, driven by a set of algorithms divided into task-oriented functions operating on shared, external data. For example, if we declare a struct Point3d, such as the following:
typedef struct point3d
{
float x;
float y;
float z;
} Point3d; the operation to print a particular Point3d might be defined either as a function
void
Point3d_print( const Point3d *pd )
{
printf(”( %g, %g, %g )”, pd->x, pd->y, pd->z );
} or, for efficiency, as a preprocessor macro:
#define Point3d_print( pd ) \ printf(”( %g, %g, %g )”, ...
Read now
Unlock full access