#ifndef _POLYNOMIAL_H #define _POLYNOMIAL_H #include \"linked_list.h\" #include
ID: 3629001 • Letter: #
Question
#ifndef _POLYNOMIAL_H#define _POLYNOMIAL_H
#include "linked_list.h"
#include "globals.h"
typedef list polynomial; /* blech */
typedef struct term {
int coefficient;
int degree;
} term; /* blech */
extern status read_poly (polynomial *p_poly);
extern void write_poly (polynomial p_poly);
extern status add_poly (polynomial *p_poly1, polynomial *p_poly2);
extern void destroy_poly (polynomial *p_poly);
#endif
explain why there are two comments that say “blech” in the above file. Do this in 1–3 complete sentences.
Explanation / Answer
The "blech" could be inserted there for this reason: The user has used typedef struct term{ int coefficient; int degree; } term; When he could have written this code, that actually does the same thing and is easier to write: struct term { int coefficient; int degree; }; The only thing typedef does in this situation is hide the fact that the programmer is using a struct. If you don't know what datatype the variable is in huge code that just makes reading and maintaining the code more difficult. Thus, the programmer is using the comment /*blech*/ because he would rather not go through the trouble of writing the full typedef strcut, but he is doing it (though not enthusiastically) because it gives readers of the code (perhaps his professor) more insight as to what is going on. He would rather be lazy.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.