Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef ZAD3_H
- #define ZAD3_H
- #include <iostream>
- #include <string>
- using namespace std;
- class Shape {
- protected:
- string name;
- public:
- Shape(string n):name(n) {
- cout<<endl << "Wywolano konstruktor klasy 'Shape'" << endl;
- }
- ~Shape() {
- cout << endl << "wywolano destruktor klasy 'Shape' " << endl;
- }
- void setName(string n) { name = n; }
- string getName() { return name; }
- virtual double area() = 0;
- };
- class Rectanglee :public Shape {
- protected:
- double width;
- double height;
- public:
- Rectanglee(string n,double a, double b): Shape(n),width(a),height(b){
- cout << endl << "Wywolano konstruktor klasy 'Rectangle'" << endl;
- }
- ~Rectanglee(){
- cout << "Wywolano desturktor klasy 'Rectangle' " << endl;
- }
- double area() {
- return width*height;
- }
- };
- class Square : public Rectanglee {
- public:
- Square(string n, double a) : Rectanglee(n, a, a){
- cout << endl << "Wywolano konstruktor klasy 'Square'" << endl;
- }
- ~Square(){
- cout << endl << "Wywolano destruktor klasy 'Square'" << endl;
- }
- double area(){
- return width*width;
- }
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement