Wednesday, April 25, 2012

8.7

Given the following variable declarations in C/C++


int (*f) (int);
int (*g) (int);
int (*h) (char);


the assignment f = g is fine in C and C++ but the assignment h = g generates a compiler warning in C and a compiler error in C++. Explain


f and g are the same type, whereas h and g are different types. An integer will not fit in the space allocated for a char, and so the compiler complains

No comments:

Post a Comment