diff options
Diffstat (limited to 'reference/CPLUSPLUS/EXAMPLES/overload.cc')
-rw-r--r-- | reference/CPLUSPLUS/EXAMPLES/overload.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/reference/CPLUSPLUS/EXAMPLES/overload.cc b/reference/CPLUSPLUS/EXAMPLES/overload.cc new file mode 100644 index 0000000..cd8a720 --- /dev/null +++ b/reference/CPLUSPLUS/EXAMPLES/overload.cc @@ -0,0 +1,27 @@ +
+ #include <iostream.h>
+
+ void Add(int Left, int Right);
+ void Add(double Left, double Right);
+
+ main ()
+ {
+
+ Add(5, 9);
+ Add(3.2, 7.1);
+ }
+
+ // integer version of Add.
+
+ void Add(int Left, int Right)
+ {
+ cout << Left << " + " << Right << " = " << Left+Right << endl;
+ }
+
+ // float version of Add.
+
+ void Add(double Left, double Right)
+ {
+ cout << Left << " + " << Right << " = " << Left+Right << endl;
+ }
+
|