home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / bcpp / file19 / shape.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  1.3 KB  |  43 lines

  1. ////////////////////////////////////////////////////////////
  2. // shape.h: A class used for testing.
  3. // *** Modified from book code, to take out reference
  4. //     counts. (Not needed for our tests here.) ***
  5. // Copyright(c) 1993 Azarona Software. All rights reserved. 
  6. ////////////////////////////////////////////////////////////
  7. #ifndef H_SHAPE
  8. #define H_SHAPE
  9. #include <iostream.h>
  10.  
  11.  
  12. struct Shape {
  13.   static int objects_needing_destruction, verbose;
  14.   int x, y;
  15.   Shape();
  16.   Shape(const Shape &p);
  17.   Shape(int xx, int yy);
  18.   virtual ~Shape();
  19.   Shape &operator=(const Shape &p);
  20.   friend int operator==(const Shape &a, const Shape &b);
  21.   friend int operator<(const Shape &a, const Shape &b);
  22.   friend int operator>(const Shape &a, const Shape &b);
  23.   virtual ostream &Print(ostream &os) const;
  24.   virtual int Area() const { return 0; }
  25. };
  26.  
  27. struct Circle : public Shape {
  28.   int r;
  29.   Circle();
  30.   Circle(const Circle &c);
  31.   Circle(int xx, int yy, int rr);
  32.   virtual ~Circle();
  33.   Circle &operator=(const Circle &c);
  34.   friend int operator==(const Circle &a, const Circle &b);
  35.   virtual ostream &Print(ostream &os) const;
  36.   virtual int Area() const { return 3 * r * r; }
  37. };
  38.  
  39. ostream &operator<<(ostream &os, const Shape &p);
  40. ostream &operator<<(ostream &os, const Circle &c);
  41.  
  42. #endif
  43.