PageRenderTime 39ms CodeModel.GetById 35ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/contract/simple_cxx/example.h

#
C++ Header | 34 lines | 30 code | 3 blank | 1 comment | 0 complexity | 297367c3116721edbe49fd016a6fbe6e MD5 | raw file
 1/* File : example.h */
 2
 3class Shape {
 4public:
 5  Shape() {
 6    nshapes++;
 7  }
 8  virtual ~Shape() {
 9    nshapes--;
10  };
11  double  x, y;   
12  void    move(double dx, double dy);
13  virtual double area(void) = 0;
14  virtual double perimeter(void) = 0;
15  static  int nshapes;
16};
17
18class Circle : public Shape {
19private:
20  double radius;
21public:
22  Circle(double r) : radius(r) { };
23  virtual double area(void);
24  virtual double perimeter(void);
25};
26
27class Square : public Shape {
28private:
29  double width;
30public:
31  Square(double w) : width(w) { };
32  virtual double area(void);
33  virtual double perimeter(void);
34};