Mail Archives: djgpp/1998/09/07/22:04:39
Ralph Proctor wrote:
> >Overloading is also a major function, with the
> >iostream being the prime example of this.
> This I don't understand.
Here is an example of function overloading:
void Print(int a);
void Print(float a);
void Print(char* a);
//In C you would have to use different names:
void PrintInt(int a);
void PrintFloat(float a);
void PrintString(char* a);
// Or
void Print(char* format, ...);
// But that is slightly annoying to program.
You can also do the same thing with operators:
struct Complex {int real,fake;}
Complex operator + (Complex a, Complex b);
//This function will be called anytime you do something like this:
Complex A,B,C;
A = B+C; //Called here.
--
(\/) Endlisnis (\/)
s257m AT unb DOT ca
Endlisnis AT GeoCities DOT com
Endlis AT nbnet DOT nb DOT ca
- Raw text -