Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Czworokat
- {
- protected:
- double a,b,c,d;
- public:
- Czworokat()
- {
- }
- Czworokat(double a, double b, double c, double d)
- {
- this->a=a;
- this->b=b;
- this->c=c;
- this->d=d;
- }
- void wypisz()
- {
- cout<<endl<<"Dlugosc boku a:"<<a;
- cout<<endl<<"Dlugosc boku b:"<<b;
- cout<<endl<<"Dlugosc boku c:"<<c;
- cout<<endl<<"Dlugosc boku d:"<<d;
- }
- virtual double oblicz_pole();
- };
- class Prostokat: public Czworokat
- {
- public:
- Prostokat()
- {
- }
- Prostokat(double a, double c)
- {
- this->a=a;
- this->b=a;
- this->c=c;
- this->d=c;
- }
- double oblicz_pole()
- {
- return a*c;
- }
- void wymiary(double a,double c)
- {
- this->a=a;
- this->b=a;
- this->c=c;
- this->d=c;
- }
- };
- class Kwadrat: public Prostokat
- {
- public:
- Kwadrat()
- {
- }
- Kwadrat(double a)
- {
- this->a=a;
- this->b=a;
- this->c=a;
- this->d=a;
- }
- double oblicz_pole()
- {
- return a*a;
- }
- void wymiar(double a)
- {
- this->a=a;
- this->b=a;
- this->c=a;
- this->d=a;
- }
- };
- int main()
- {
- Czworokat *czworokat_1=new Czworokat(1,2,3,4);
- czworokat_1->wypisz();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement