8 8 votes Which one of the following is correct about the statements given below? All function calls are resolved at compile time in C lang All function calls are resolved at compile time in C++ lang Only II is correct Both I and II are correct Only I is correct Both I and II are incorrect Programming in C isro2016 programming-in-c + – Desert_Warrior 8.7k views answer comment Share Follow Print See all 2 Comments 2 2 Comments reply Desert_Warrior commented Jul 3, 2016 reply Follow flag option B ? 0 0 replyShare LeenSharma commented Jul 3, 2016 reply Follow flag no,option(c) should be the answer here. 0 0 replyShare Please log in or register to add a comment.
Best answer 14 14 votes Consider here: int (*p) (); scanf("%d", &a); if(a) p = fun1; else p = fun2; int b = (*p)(); This is an example of run time resolution of function calls in C. This is also applicable for C++ though it has other dynamic resolution via virtual functions. So, answer should be D. Arjun answered Jul 4, 2016 • selected Mar 7, 2018 by srestha Arjun comment Share Follow See all 7 Comments 7 7 Comments reply Show 4 previous comments habedo007 commented Jul 18, 2016 reply Follow flag The example you gave here, sir, is of function pointer actually. Both of them are resolved during linking time only. It is the matter of determining the address of which function to be called, which is being done here. 0 0 replyShare Arjun commented Jul 18, 2016 reply Follow flag Without getting the address what is resolved at link time? 0 0 replyShare habedo007 commented Jul 19, 2016 reply Follow flag The functions are getting resolved at link time just like every other functions do, sir. Importantly, what this if-else statement is doing is determining the address to which the control flow needs to be transferred when the function is called. If you want, you can stretch the definition of polymorphism and include this in it and call it static polymorphism, as this example here has an interface to call the functions instead of letting compiler decide it. 1 1 replyShare Please log in or register to add a comment.
7 7 votes (1) C supports only "Early Binding" in which all the functions related to their function calls are resolved at compile time. (2)C++ Supports both "Early Binding" and "Late Binding".Late Binding is the process of resolving functions related to function calls during Run time. In C++ virtual calling mechanisms are resolved at run-time. Hence,Option(c)only 1 correct. LeenSharma answered Jul 3, 2016 LeenSharma comment Share Follow 0 reply Please log in or register to add a comment.