8,728 views
8 8 votes

Which one of the following is correct about the statements given below?

  1. All function calls are resolved at compile time in C lang
  2. All function calls are resolved at compile time in C++ lang
  1. Only II is correct
  2. Both I and II are correct
  3. Only I is correct
  4. Both I and II are incorrect

2 Answers

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. 

selected by
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.

Answer:
Position:
Show:

Related questions

11 11 votes
2 answers 2 answers
10.4k
10.4k views
sourav. asked Jul 3, 2016
10,445 views
What will be output of the following program? Assume that you are running this program in little-endian processor.#include<stdio.h int main() { short a=320; char *ptr; pt...
4 4 votes
4 answers 4 answers
5.2k
5.2k views
sourav. asked Jul 3, 2016
5,174 views
What is the output of this C code?#include<stdio.h void main() { int k=5; int *p=&k; int m=&p; printf("%d %d %d",k,*p, m); }5 5 5 5 5 junk5 junk junkcompile time error
8 8 votes
2 answers 2 answers
4.7k
4.7k views
Arjun asked Jul 6, 2016
4,749 views
A simple two-pass assembler does which of the following in the first pass:Checks to see if the instructions are legal in the current assembly modeIt allocates space for t...
8 8 votes
3 answers 3 answers
12.5k
12.5k views
Arjun asked Jul 6, 2016
12,479 views
At a particular time of computation the value of a counting semaphore is 7. Then 20 $P$ operations and $x$ $V$ operations were completed on this semaphore. If the new val...