Various C++ Examples (including IPC)  Version: 1.0.0
overload.cc
Go to the documentation of this file.
1 
5 #include <stdio.h>
6 
7 /*
8  this won't compile -can't overload functions by return type. The
9  compiler sees this as ambiguious.
10 */
11 
12 int thing1()
13 {
14  printf( "thing1\n");
15  return 1;
16 }
17 
18 int thing1(int i)
19 {
20  printf( "thing1a\n" );
21  return 0;
22 }
23 
24 double thing2()
25 {
26  printf( "thing2\n");
27  return 'x';
28 }
29 double thing2(int i)
30 {
31  printf( "thing2a\n" );
32  return 0;
33 }
34 
35 
36 
37 int main(int argc, char **argv)
38 {
39  int x;
40  double y;
41 
42  x = thing1();
43  x = thing1(1);
44 
45  y = thing2();
46  y = thing2(1);
47 }
int main(int argc, char **argv)
Definition: overload.cc:37
double thing2()
Definition: overload.cc:24
int thing1()
Definition: overload.cc:12