~ubuntu-branches/ubuntu/edgy/swig1.3/edgy

« back to all changes in this revision

Viewing changes to Examples/php4/overloading/example.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:16:04 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205011604-ygx904it6413k3go
Tags: 1.3.27-1ubuntu1
Resynchronise with Debian again, for the new subversion packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* File : example.c */
 
2
 
 
3
#include "example.h"
 
4
#include <math.h>
 
5
#ifndef M_PI
 
6
#  define M_PI 3.14159265358979323846
 
7
#endif
 
8
 
 
9
int Shape::get_nshapes() {
 
10
  return nshapes;
 
11
}
 
12
 
 
13
/* Move the shape to a new location */
 
14
void Shape::move(double dx, double dy) {
 
15
  x += dx;
 
16
  y += dy;
 
17
}
 
18
 
 
19
int Shape::nshapes = 0;
 
20
 
 
21
double Circle::area(void) {
 
22
  return M_PI*radius*radius;
 
23
}
 
24
 
 
25
double Circle::perimeter(void) {
 
26
  return 2*M_PI*radius;
 
27
}
 
28
 
 
29
double Square::area(void) {
 
30
  return width*width;
 
31
}
 
32
 
 
33
double Square::perimeter(void) {
 
34
  return 4*width;
 
35
}
 
36
 
 
37
char *overloaded(int i) {
 
38
  return "Overloaded with int";
 
39
}
 
40
 
 
41
char *overloaded(double d) {
 
42
  return "Overloaded with double";
 
43
}
 
44
 
 
45
char *overloaded( const Circle& ) {
 
46
  return "Overloaded with Circle";
 
47
}
 
48
 
 
49
char *overloaded( const Shape& ) {
 
50
  return "Overloaded with Shape";
 
51
}