guys i have a one question relates to point structure declaration,when i was reading tutorial about geometric data types declaration ,i have seen two strange things which confused me, i will show these things right know
typedef double point[DIMENSION];
typedef struct {
int n; /* number of points in polygon */
point p[MAXPOLY]; /* array of points in polygon */
} polygon;
typedef struct {
point p1,p2; /* endpoints of line segment */
} segment;
typedef point triangle[3]; /* triangle datatype */
let us suppose that dimension is some number for example (2) and maxpoly maxsimum number of points in polygon,i am confused with declaration of point
what does this means typedef double point[dimension]?,i know what is typedef ,but in case of we declare point as double array,then how can we use it in another structure
or class as a object?like struct array?
consider this
typedef truct
{
point p1,p2;
}segment;
how correct it is?please help me to understand this
Something defined using
typedefis just an alias (i.e. another name) of another type.In your case
This defines the name
pointto mean “an array of size DIMENSION of the type double”.After this, instead of writing
You can write
If the typedef is in a header file, the name can be used in all source and header files including the header file with the typedef.