Update scilab examples from other languages
This commit is contained in:
parent
37c411958e
commit
7af54ec169
4 changed files with 15 additions and 18 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
/* File : example.c */
|
/* File : example.cxx */
|
||||||
|
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
#define M_PI 3.14159265358979323846
|
#define M_PI 3.14159265358979323846
|
||||||
|
|
@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
|
||||||
|
|
||||||
int Shape::nshapes = 0;
|
int Shape::nshapes = 0;
|
||||||
|
|
||||||
double Circle::area(void) {
|
double Circle::area() {
|
||||||
return M_PI*radius*radius;
|
return M_PI*radius*radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Circle::perimeter(void) {
|
double Circle::perimeter() {
|
||||||
return 2*M_PI*radius;
|
return 2*M_PI*radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Square::area(void) {
|
double Square::area() {
|
||||||
return width*width;
|
return width*width;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Square::perimeter(void) {
|
double Square::perimeter() {
|
||||||
return 4*width;
|
return 4*width;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ public:
|
||||||
}
|
}
|
||||||
virtual ~Shape() {
|
virtual ~Shape() {
|
||||||
nshapes--;
|
nshapes--;
|
||||||
};
|
}
|
||||||
double x, y;
|
double x, y;
|
||||||
void move(double dx, double dy);
|
void move(double dx, double dy);
|
||||||
virtual double area(void) = 0;
|
virtual double area() = 0;
|
||||||
virtual double perimeter(void) = 0;
|
virtual double perimeter() = 0;
|
||||||
static int nshapes;
|
static int nshapes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -19,17 +19,16 @@ class Circle : public Shape {
|
||||||
private:
|
private:
|
||||||
double radius;
|
double radius;
|
||||||
public:
|
public:
|
||||||
Circle(double r) : radius(r) { };
|
Circle(double r) : radius(r) { }
|
||||||
virtual double area(void);
|
virtual double area();
|
||||||
virtual double perimeter(void);
|
virtual double perimeter();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Square : public Shape {
|
class Square : public Shape {
|
||||||
private:
|
private:
|
||||||
double width;
|
double width;
|
||||||
public:
|
public:
|
||||||
Square(double w) : width(w) { };
|
Square(double w) : width(w) { }
|
||||||
virtual double area(void);
|
virtual double area();
|
||||||
virtual double perimeter(void);
|
virtual double perimeter();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,3 @@
|
||||||
|
|
||||||
/* Let's just grab the original header file here */
|
/* Let's just grab the original header file here */
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,3 @@ int mul(int a, int b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int (*funcvar)(int,int) = add;
|
int (*funcvar)(int,int) = add;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue