InterviewSolution
| 1. |
Why doesn’t C support function overloading? |
|
Answer» After you compile the C SOURCE, the symbol names NEED to be intact in the object code. If we introduce function overloading in our source, we should also provide name mangling as a preventive measure to avoid function name CLASHES. Also, as C is not a strictly TYPED language many things(ex: data types) are CONVERTIBLE to each other in C. Therefore, the complexity of overload resolution can introduce confusion in a language such as C. When you compile a C source, symbol names will remain intact. If you introduce function overloading, you should provide a name mangling technique to prevent name clashes. Consequently, like C++, you'll have machine-generated symbol names in the compiled binary. Additionally, C does not feature strict typing. Many things are implicitly convertible to each other in C. The complexity of overload resolution rules could introduce confusion in such kind of language |
|