-
#define M_PI 3.14159265358979323846
-// Static member initializer
-int Shape::nshapes = 0;
-
-// Constructor
-Shape::Shape() {
- nshapes++;
-}
-
-// Move the shape to a new location
+/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
-// Destructor
-Shape::~Shape() {
- nshapes--;
-}
+int Shape::nshapes = 0;
-// Circle area
-double Circle::area() const {
+double Circle::area() {
return M_PI*radius*radius;
}
-// Circle perimeter
-double Circle::perimeter() const {
+double Circle::perimeter() {
return 2*M_PI*radius;
}
-// Square area
-double Square::area() const {
+double Square::area() {
return width*width;
}
-// Square perimeter
-double Square::perimeter() const {
+double Square::perimeter() {
return 4*width;
}
diff --git a/Examples/pike/class/example.h b/Examples/pike/class/example.h
index f74a4fefc..0dff185b2 100644
--- a/Examples/pike/class/example.h
+++ b/Examples/pike/class/example.h
@@ -2,12 +2,16 @@
class Shape {
public:
- Shape();
- virtual ~Shape();
- double x, y;
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ }
+ double x, y;
void move(double dx, double dy);
- virtual double area() const = 0;
- virtual double perimeter() const = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
@@ -15,21 +19,16 @@ class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area() const;
- virtual double perimeter() const;
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area() const;
- virtual double perimeter() const;
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
-
-
-
-
-
diff --git a/Examples/pike/class/example.i b/Examples/pike/class/example.i
index 75700b305..fbdf7249f 100644
--- a/Examples/pike/class/example.i
+++ b/Examples/pike/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
diff --git a/Examples/python/class/example.i b/Examples/python/class/example.i
index 75700b305..fbdf7249f 100644
--- a/Examples/python/class/example.i
+++ b/Examples/python/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
diff --git a/Examples/r/class/example.h b/Examples/r/class/example.h
index 46d901361..0dff185b2 100644
--- a/Examples/r/class/example.h
+++ b/Examples/r/class/example.h
@@ -7,11 +7,11 @@ public:
}
virtual ~Shape() {
nshapes--;
- };
- double x, y;
+ }
+ double x, y;
void move(double dx, double dy);
- virtual double area(void) = 0;
- virtual double perimeter(void) = 0;
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
static int nshapes;
};
@@ -19,21 +19,16 @@ class Circle : public Shape {
private:
double radius;
public:
- Circle(double r) : radius(r) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
- Square(double w) : width(w) { };
- virtual double area(void);
- virtual double perimeter(void);
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
};
-
-
-
-
-
diff --git a/Examples/r/class/example.i b/Examples/r/class/example.i
index 4654d269f..fbdf7249f 100644
--- a/Examples/r/class/example.i
+++ b/Examples/r/class/example.i
@@ -1,9 +1,9 @@
/* File : example.i */
%module example
-%inline %{
+%{
#include "example.h"
%}
+
+/* Let's just grab the original header file here */
%include "example.h"
-
-
diff --git a/Examples/ruby/class/example.i b/Examples/ruby/class/example.i
index 75700b305..fbdf7249f 100644
--- a/Examples/ruby/class/example.i
+++ b/Examples/ruby/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
diff --git a/Examples/ruby/class/index.html b/Examples/ruby/class/index.html
index 1e227342d..927c00190 100644
--- a/Examples/ruby/class/index.html
+++ b/Examples/ruby/class/index.html
@@ -12,7 +12,7 @@
Wrapping a simple C++ class
-This example illustrates wrapping a simple C++ class to give a Python class.
+This example illustrates wrapping a simple C++ class to give a Ruby class.
The C++ Code
@@ -147,7 +147,7 @@ due to Ruby's sophisticated extension API.
SWIG does know how to properly perform upcasting of objects in
an inheritance hierarchy except for multiple inheritance.
-C++ Namespaces - %nspace isn't yet supported for Python.
+C++ Namespaces - %nspace isn't yet supported for Ruby.
diff --git a/Examples/tcl/class/example.i b/Examples/tcl/class/example.i
index 75700b305..fbdf7249f 100644
--- a/Examples/tcl/class/example.i
+++ b/Examples/tcl/class/example.i
@@ -7,4 +7,3 @@
/* Let's just grab the original header file here */
%include "example.h"
-
diff --git a/Examples/tcl/class/index.html b/Examples/tcl/class/index.html
index 5b09b7a9d..16dbeea4f 100644
--- a/Examples/tcl/class/index.html
+++ b/Examples/tcl/class/index.html
@@ -229,11 +229,11 @@ set Shapes_nshapes 13 # Set a static data member
The low-level function interface is much faster than the high-level interface.
In fact, all the higher level interface does is call functions in the low-level interface.
-SWIG *does* know how to properly perform upcasting of objects in an inheritance
+SWIG does know how to properly perform upcasting of objects in an inheritance
hierarchy (including multiple inheritance). Therefore it is perfectly safe to pass
an object of a derived class to any function involving a base class.
-C++ Namespaces - %nspace isn't yet supported for Python.
+C++ Namespaces - %nspace isn't yet supported for Tcl.