This is a really bad idea:
char *p=(char *)&d1;
*p=1;
Your code should never make assumptions about the internal structure of a class. If your class had any virtual functions, for example, this code will fail when it is called.
, Distance :
class Distance {
short feet;
float inches;
public:
void setFeet(...
};
setFeet(256), (MSB) 1 (256 = 1 * 2 ^ 8), (LSB) - 0. 1 char Distance, short, , 1. , short , 1, 1 * 2^8 + 1 = 257.
256, , 1 , 1.
, undefined, , . comp.lang.c , undefined ".