What is function overriding in C
What may I kno,is meant by function overriding
|
There is no function overriding in C, only in C++. Try a google search on C++ function overriding and you'll find more information than you need.
|
In a language that support overriding (which C does not), this usually means that you can redefine an existing function, exactly as it is declared, and define it as you like. For example, let's say that language X defines the print function as:
Code:
# ficticious language X print function Code:
int print:override(va_arg_list) { Hope this helps! |
About function overriding in C.
I also thought that that's not possible, but then, how come this is possible? Code:
shell$ man fcntl To me, this looks like a (limited?) form of function overriding (in C). I've been wondering before how this is achieved. Anyone? |
Because C doesn't require that you pass all parameters to the function if you leave the parameter list blank in the prototype. The compiler should only throw up warnings if the prototype has a non-empty parameter list and you don't pass enough enough arguments to the function.
Code:
itsme@dreams:~/C$ cat param.c |
actually fcnt is defined in the header file using
int fcntl (int fd, int cmd, ...); This means it can take variable number of arguments. now it looks at the command and then decides if anything follows as the third parameter or not. see man va_arg etc for more details. |
Please don't post this in two places, even if it is under another username....
http://www.linuxquestions.org/questi...hreadid=300378 |
Quote:
|
All times are GMT -5. The time now is 01:21 AM. |