I came across this code, and I was interested what the constructs marked below by comments //<-- This
are.
If it has a name then I would like to know (to google it and get more info if possible).
#include <stdio.h>
typedef struct point {
float x,y;
void print(void);
} dot;
typedef struct rect {
dot pt1,pt2;
float area(void);
dot center(void);
void print(void);
} rectangle;
void dot::print(void){ //<-- This
printf("(%3.1f,%3.1f)", x, y);
}
void rectangle::print(void){ //<-- This
pt1.print(); printf(":"); pt2.print();
}
dot rectangle::center(void){ //<-- This
dot c; c.x=(pt1.x + pt2.x)/2;
c.y=(pt1.y + pt2.y)/2; return c;
}
float rectangle::area(void){ //<-- This
return((pt2.x-pt1.x)*(pt2.y-pt1.y));
}