Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #ifndef ZAD3_H
  2. #define ZAD3_H
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. class Shape {
  8.  
  9. protected:
  10. string name;
  11. public:
  12. Shape(string n):name(n) {
  13. cout<<endl << "Wywolano konstruktor klasy 'Shape'" << endl;
  14. }
  15. ~Shape() {
  16. cout << endl << "wywolano destruktor klasy 'Shape' " << endl;
  17. }
  18. void setName(string n) { name = n; }
  19. string getName() { return name; }
  20. virtual double area() = 0;
  21. };
  22.  
  23. class Rectanglee :public Shape {
  24. protected:
  25. double width;
  26. double height;
  27. public:
  28. Rectanglee(string n,double a, double b): Shape(n),width(a),height(b){
  29. cout << endl << "Wywolano konstruktor klasy 'Rectangle'" << endl;
  30. }
  31. ~Rectanglee(){
  32. cout << "Wywolano desturktor klasy 'Rectangle' " << endl;
  33. }
  34. double area() {
  35. return width*height;
  36. }
  37. };
  38.  
  39. class Square : public Rectanglee {
  40. public:
  41. Square(string n, double a) : Rectanglee(n, a, a){
  42. cout << endl << "Wywolano konstruktor klasy 'Square'" << endl;
  43. }
  44. ~Square(){
  45. cout << endl << "Wywolano destruktor klasy 'Square'" << endl;
  46. }
  47. double area(){
  48. return width*width;
  49. }
  50. };
  51.  
  52. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement