karthik schrieb:
The * operator behaves in 2 different ways. It is used as the value at
address operator as well as the multiplication operator. Does this mean
* is overloaded in c?
No, this is not overloading, it is multiple use of the same
character as operator.
One is as a unary operator, the other as a binary operator
and there is no danger that the compiler ever confuses them
in context[*].
If you want to see it as such, then overloading takes place
for the binary operator itself and the unary operator itself:
- binary * can multiplicate pairs of ints, unsigned ints, longs,
unsigned longs, doubles, long doubles (type promotion and
arithmetical conversions take care of the rest in C90), so
if "int" is your original argument type, then the rest is
overloaded.
- unary * can get the value of the different builtin types
_and_ for user defined types like structures, i.e. whenever
you write "struct foo {....};", * is overloaded, such that
for "struct foo *pFoo;" applying * to pFoo yields a
struct foo object.
Another point of view is to say that there is no operator
overloading in standard C.
At least one C implementation provides operator overloading
as compiler extension[**].
With C99, there are "type generic math functions" which
effectively are overloaded but there is no function
overloading as such.
Cheers
Michael
[*] This danger is given for "i---j"
[**] lcc-win32
--
E-Mail: Mine is an /at/ gmx /dot/ de address.