ok i know what this does...it allows to functions of the same name have different data,but why would i use this? why not just create a different function name
ok i know what this does...it allows to functions of the same name have different data,but why would i use this? why not just create a different function name
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Function overloading can be very handy. If you were creating say a game, you could use two functions with the same name but with different arguements say for two enemys. But you could still call both functions Enemy().
Also, in operator overloading, you can make the standard C++ operators do differnet things, example, you could make the '+' operator subtract for example. But messing with logical operators is somthing I am always keen to stay away from. If an operator was built to do a certaun thing, why change it?
I'm sure you use function overloading all the time, without even thinking about it:
Code:std::string str; int i; double d; char c; my_special_class myc; std::cout << str << i << d << c << myc << "\n"; //here operator << is overloaded for various types to print a variable
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}
well then,i suppose it definetly couldnt hurt to learn it.to say the least..and also,why did bs decide to let you change the operators?that seems odd what would be the point of making + equal -
That's abuse of operator overloading. It can be very useful when used properly, however. I'm sure you've used the + operator for strings to concatenate strings together, and =, <, and > to compare them.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.