/tags/rel-1-3-26/SWIG/Examples/ruby/overloading/example.cxx
C++ | 125 lines | 89 code | 32 blank | 4 comment | 0 complexity | 1615dec4422e7d7c23243b9f72afce35 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1#include <iostream> 2 3#include "example.h" 4 5// Overloaded constructors for class Bar 6Bar::Bar() { 7 std::cout << "Called Bar::Bar()" << std::endl; 8} 9 10Bar::Bar(const Bar&) { 11 std::cout << "Called Bar::Bar(const Bar&)" << std::endl; 12} 13 14Bar::Bar(double x) { 15 std::cout << "Called Bar::Bar(double) with x = " << x << std::endl; 16} 17 18Bar::Bar(double x, char *y) { 19 std::cout << "Called Bar::Bar(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; 20} 21 22Bar::Bar(int x, int y) { 23 std::cout << "Called Bar::Bar(int, int) with x, y = " << x << ", " << y << std::endl; 24} 25 26Bar::Bar(char *x) { 27 std::cout << "Called Bar::Bar(char *) with x = \"" << x << "\"" << std::endl; 28} 29 30Bar::Bar(int x) { 31 std::cout << "Called Bar::Bar(int) with x = " << x << std::endl; 32} 33 34Bar::Bar(long x) { 35 std::cout << "Called Bar::Bar(long) with x = " << x << std::endl; 36} 37 38Bar::Bar(Bar *x) { 39 std::cout << "Called Bar::Bar(Bar *) with x = " << x << std::endl; 40} 41 42// Overloaded member functions 43void Bar::foo(const Bar& x) { 44 std::cout << "Called Bar::foo(const Bar&) with &x = " << &x << std::endl; 45} 46 47void Bar::foo(double x) { 48 std::cout << "Called Bar::foo(double) with x = " << x << std::endl; 49} 50 51void Bar::foo(double x, char *y) { 52 std::cout << "Called Bar::foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; 53} 54 55void Bar::foo(int x, int y) { 56 std::cout << "Called Bar::foo(int, int) with x, y = " << x << ", " << y << std::endl; 57} 58 59void Bar::foo(char *x) { 60 std::cout << "Called Bar::foo(char *) with x = \"" << x << "\"" << std::endl; 61} 62 63void Bar::foo(int x) { 64 std::cout << "Called Bar::foo(int) with x = " << x << std::endl; 65} 66 67void Bar::foo(long x) { 68 std::cout << "Called Bar::foo(long) with x = " << x << std::endl; 69} 70 71void Bar::foo(Bar *x) { 72 std::cout << "Called Bar::foo(Bar *) with x = " << x << std::endl; 73} 74 75void Bar::spam(int x, int y, int z) { 76 std::cout << "Called Bar::spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; 77} 78 79void Bar::spam(double x, int y, int z) { 80 std::cout << "Called Bar::spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; 81} 82 83// Overloaded global methods 84void foo(const Bar& x) { 85 std::cout << "Called foo(const Bar& x) with &x = " << &x << std::endl; 86} 87 88void foo(double x) { 89 std::cout << "Called foo(double) with x = " << x << std::endl; 90} 91 92void foo(double x, char *y) { 93 std::cout << "Called foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; 94} 95 96void foo(int x, int y) { 97 std::cout << "Called foo(int, int) with x, y = " << x << ", " << y << std::endl; 98} 99 100void foo(char *x) { 101 std::cout << "Called foo(char *) with x = \"" << x << "\"" << std::endl; 102} 103 104void foo(int x) { 105 std::cout << "Called foo(int) with x = " << x << std::endl; 106} 107 108void foo(long x) { 109 std::cout << "Called foo(long) with x = " << x << std::endl; 110} 111 112void foo(Bar *x) { 113 std::cout << "Called foo(Bar *) with x = " << x << std::endl; 114} 115 116// Overloaded global spam() functions 117void spam(int x, int y, int z) { 118 std::cout << "Called spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; 119} 120 121void spam(double x, int y, int z) { 122 std::cout << "Called spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; 123} 124 125