diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2009-08-18 20:56:02 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-25 16:59:08 +0000 |
commit | 9f8a09ed743cedd9547bf0661d518647966ab114 (patch) | |
tree | 9c7803d3b27a8ec22e91792ac7f7932efa128b20 /Examples/ruby/overloading/example.cxx | |
download | swig-tarball-master.tar.gz |
Imported from /srv/lorry/lorry-area/swig-tarball/swig-1.3.40.tar.gz.HEADswig-1.3.40master
Diffstat (limited to 'Examples/ruby/overloading/example.cxx')
-rw-r--r-- | Examples/ruby/overloading/example.cxx | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/Examples/ruby/overloading/example.cxx b/Examples/ruby/overloading/example.cxx new file mode 100644 index 0000000..49d998d --- /dev/null +++ b/Examples/ruby/overloading/example.cxx @@ -0,0 +1,125 @@ +#include <iostream> + +#include "example.h" + +// Overloaded constructors for class Bar +Bar::Bar() { + std::cout << "Called Bar::Bar()" << std::endl; +} + +Bar::Bar(const Bar&) { + std::cout << "Called Bar::Bar(const Bar&)" << std::endl; +} + +Bar::Bar(double x) { + std::cout << "Called Bar::Bar(double) with x = " << x << std::endl; +} + +Bar::Bar(double x, char *y) { + std::cout << "Called Bar::Bar(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; +} + +Bar::Bar(int x, int y) { + std::cout << "Called Bar::Bar(int, int) with x, y = " << x << ", " << y << std::endl; +} + +Bar::Bar(char *x) { + std::cout << "Called Bar::Bar(char *) with x = \"" << x << "\"" << std::endl; +} + +Bar::Bar(int x) { + std::cout << "Called Bar::Bar(int) with x = " << x << std::endl; +} + +Bar::Bar(long x) { + std::cout << "Called Bar::Bar(long) with x = " << x << std::endl; +} + +Bar::Bar(Bar *x) { + std::cout << "Called Bar::Bar(Bar *) with x = " << x << std::endl; +} + +// Overloaded member functions +void Bar::foo(const Bar& x) { + std::cout << "Called Bar::foo(const Bar&) with &x = " << &x << std::endl; +} + +void Bar::foo(double x) { + std::cout << "Called Bar::foo(double) with x = " << x << std::endl; +} + +void Bar::foo(double x, char *y) { + std::cout << "Called Bar::foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; +} + +void Bar::foo(int x, int y) { + std::cout << "Called Bar::foo(int, int) with x, y = " << x << ", " << y << std::endl; +} + +void Bar::foo(char *x) { + std::cout << "Called Bar::foo(char *) with x = \"" << x << "\"" << std::endl; +} + +void Bar::foo(int x) { + std::cout << "Called Bar::foo(int) with x = " << x << std::endl; +} + +void Bar::foo(long x) { + std::cout << "Called Bar::foo(long) with x = " << x << std::endl; +} + +void Bar::foo(Bar *x) { + std::cout << "Called Bar::foo(Bar *) with x = " << x << std::endl; +} + +void Bar::spam(int x, int y, int z) { + std::cout << "Called Bar::spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; +} + +void Bar::spam(double x, int y, int z) { + std::cout << "Called Bar::spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; +} + +// Overloaded global methods +void foo(const Bar& x) { + std::cout << "Called foo(const Bar& x) with &x = " << &x << std::endl; +} + +void foo(double x) { + std::cout << "Called foo(double) with x = " << x << std::endl; +} + +void foo(double x, char *y) { + std::cout << "Called foo(double, char *) with x, y = " << x << ", \"" << y << "\"" << std::endl; +} + +void foo(int x, int y) { + std::cout << "Called foo(int, int) with x, y = " << x << ", " << y << std::endl; +} + +void foo(char *x) { + std::cout << "Called foo(char *) with x = \"" << x << "\"" << std::endl; +} + +void foo(int x) { + std::cout << "Called foo(int) with x = " << x << std::endl; +} + +void foo(long x) { + std::cout << "Called foo(long) with x = " << x << std::endl; +} + +void foo(Bar *x) { + std::cout << "Called foo(Bar *) with x = " << x << std::endl; +} + +// Overloaded global spam() functions +void spam(int x, int y, int z) { + std::cout << "Called spam(int, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; +} + +void spam(double x, int y, int z) { + std::cout << "Called spam(double, int, int) with x, y, z = " << x << ", " << y << ", " << z << std::endl; +} + + |