home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX1210.CPP
-
- #include <iostream.h>
-
- void f() {
- cout << "You called f() with no arguments." << endl;
- }
-
- void f(int i) {
- cout << "You called f(int): " << i << endl;
- }
-
- void f(float i, int j) {
- cout << "You called f(float, int) " << i
- << ", " << j << endl;
- }
-
- void f(int i, float j) {
- cout << "You called f(int, float) " << i
- << ", " << j << endl;
- }
-
- void main() {
- int i = 3;
- short k = 5;
- float fl = 3.14;
- double dl = 1.33;
- f(); // invokes f()
- f(i); // invokes f(int)
- f(fl); // invokes f(int)
- f(i, fl); // invokes f(int, float)
- f(fl, i); // invokes f(float, int)
- f(dl, k); // invokes f(float, int)
- //f(i, j); // ambiguous: f(int, float) or f(float, int)
-
- }
-