summaryrefslogtreecommitdiff
path: root/Examples/guile/class/example.cxx
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2013-04-29 19:06:44 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2013-04-30 07:28:29 +0100
commitac596eb8a3bce7d4d72dce78c7a8b12014a3b428 (patch)
tree1adc07f0f8cc18ad249d4a74621c52e1ca2714da /Examples/guile/class/example.cxx
parentae1c39591787c934429e33e134e19ffabe3da5bb (diff)
downloadswig-ac596eb8a3bce7d4d72dce78c7a8b12014a3b428.tar.gz
Add C++ class example for Guile
Also correct other example c++ makefiles
Diffstat (limited to 'Examples/guile/class/example.cxx')
-rw-r--r--Examples/guile/class/example.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/Examples/guile/class/example.cxx b/Examples/guile/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/Examples/guile/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}