Most of us think that c language doesn't support polymorphism. But actually it does, think i am wrong, actually i can prove it to you..
Consider a normal printf statement, it looks something like :
printf("hai");
It also accepts another type of arguments:
printf("%d",&a); //assume a is an integer variable.
Now printf is an in-build function, it accepts two different type of arguments. In the first example it accepts a string variable , in the second one it accepts an integer variable, moreover it accepts different number of arguments, this points to the concept of function overloading which is a branch of polymorphism.
C even supports operator overloading:
& symbol-- the address operator as most of us know..but it can also be noted as a bit and operator
too. Hence a single operator can be used for multiple purposes,
There is another operator that is used for two operations.
* one is used as a pointer.
* arithmetic multiplication operator.
Most of us don't look deeply into these facts, C also supports functional and operator overloading, but it is limited to the system built-in functions,
Now in C++ these capabilities are extended to the user defined functions, and thus the concept of polymorphism emerges.
Hope this was something new....:)
Consider a normal printf statement, it looks something like :
printf("hai");
It also accepts another type of arguments:
printf("%d",&a); //assume a is an integer variable.
Now printf is an in-build function, it accepts two different type of arguments. In the first example it accepts a string variable , in the second one it accepts an integer variable, moreover it accepts different number of arguments, this points to the concept of function overloading which is a branch of polymorphism.
C even supports operator overloading:
& symbol-- the address operator as most of us know..but it can also be noted as a bit and operator
too. Hence a single operator can be used for multiple purposes,
There is another operator that is used for two operations.
* one is used as a pointer.
* arithmetic multiplication operator.
Most of us don't look deeply into these facts, C also supports functional and operator overloading, but it is limited to the system built-in functions,
Now in C++ these capabilities are extended to the user defined functions, and thus the concept of polymorphism emerges.
Hope this was something new....:)
Comments
Post a Comment