Is it possible to implement Polymorphism (either compile time / runtime) in “C” ? If yes how?

Showing Answers 1 - 3 of 3 Answers

maruthi

  • Mar 17th, 2007
 

no

  Was this answer useful?  Yes

Ashwan

  • Jul 26th, 2007
 

Dont have as such idea whether we can explicitly implement the Polymorphism or not.....but internally it gets done incase of "C".

Consider the example of printf/scanf.  Both are library functions and  can accept any number of arguments passed to them. Therefore function overloading is done here.

eg.

int main(int argc, char *argv[])
{
    printf("Enter 1 Number");
    scanf("%d",&a);                             //Scanf with 1 parameter

    printf("Enter 2 Numbers");
    scanf("%d, %d",&a, &b);               //Scanf with 2 parameters

    printf("Enter 3 Numbers");
    scanf("%d, %d, %d",&a, &b, &c); //Scanf with 3 parameters

}

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions