November 2001
Beginner
1128 pages
29h 12m
English
One of Stroustrup's pet peeves about C is its undisciplined type cast operator. True, type casts often are necessary, but the standard type cast is too unrestrictive. For example, consider the following code:
struct Doof
{
double feeb;
double steeb;
char sgif[10];
};
Doof leam;
short * ps = (short *) & leam; // old syntax
int * pi = int * (&leam); // new syntax
Nothing in the language prevents you from casting a pointer of one type to a pointer to a totally unrelated type.
In a way, the situation is similar to that of the goto statement. The problem with the goto statement was that it was too flexible, leading to twisted code. The solution was to provide more limited, structured versions of goto to handle the most common tasks for ...
Read now
Unlock full access