From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: Polymorphism in C Date: 25 Jun 2002 07:18:37 GMT Organization: Aachen University of Technology (RWTH) Lines: 35 Message-ID: References: <20020624224548 DOT 11334 DOT qmail AT web11307 DOT mail DOT yahoo DOT com> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1024989517 24245 137.226.32.75 (25 Jun 2002 07:18:37 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 25 Jun 2002 07:18:37 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Pedro Izecksohn wrote: > Hi, > In C++ polymorphism is possible, declaring more than > once the same function with different parameters, like the > example bellow: > void something (int); > void something (int *); > Is it possible in C, without using the va_* functions? Hardly. > How? By doing it the same way C++ does it, too --- mostly behind the scenes. You have to "decorate" or "mangle" the names of the function to include the types of the arguments it takes. GCC-2.8.1, e.g., will silently rename the above functions to something__Fi and something__FPi respectively, meaning "function called 'something', taking an int" and "function called 'something' taking a pointer to an int". Obviously, that's no fun at all to write by hand. Looked from this angle C++ is mainly a powerful preprocessor for C. Actually that's exactly what one of the first few C++ compilers in existence was: a preprocessor that created (almost) normal C source to be passed on to the (only slightly extended) C compiler. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.