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"
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
|
@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
|
|||
|
||||
int Shape::nshapes = 0;
|
||||
|
||||
double Circle::area(void) {
|
||||
double Circle::area() {
|
||||
return M_PI*radius*radius;
|
||||
}
|
||||
|
||||
double Circle::perimeter(void) {
|
||||
double Circle::perimeter() {
|
||||
return 2*M_PI*radius;
|
||||
}
|
||||
|
||||
double Square::area(void) {
|
||||
double Square::area() {
|
||||
return width*width;
|
||||
}
|
||||
|
||||
double Square::perimeter(void) {
|
||||
double Square::perimeter() {
|
||||
return 4*width;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,17 +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();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -7,4 +7,3 @@
|
|||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -17,4 +17,3 @@ int mul(int a, int b) {
|
|||
}
|
||||
|
||||
int (*funcvar)(int,int) = add;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue