Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication2.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <time.h>
- #include <cstdio>
- #include <string>
- using namespace std;
- #include <iostream>
- #include <stdio.h>
- #include <tchar.h>
- #include <math.h>
- class Figura {
- public:
- virtual double pole() {
- return 0.0;
- }
- virtual double obwod() {
- return 0.0;
- }
- };
- class Prostokat : public Figura {
- protected:
- double a;
- double b;
- public:
- Prostokat(double a, double b) {
- this->a = a;
- this->b = b;
- }
- ~Prostokat() {}
- virtual double pole() {
- return (this->a*this->b);
- }
- virtual double obwod() {
- return (this->a * 2 + this->b * 2);
- }
- };
- class Elipsa {
- protected:
- double a;
- double b;
- public:
- Elipsa(double a, double b) {
- this->a = a;
- this->b = b;
- }
- ~Elipsa() {}
- double pole() {
- return (this->a*this->b*3.14);
- }
- double obwod() {
- return ((3 / 2)*(this->a + this->b) - (sqrt(this->a + this->b))*3.14);
- }
- };
- class Kwadrat : public Prostokat {
- friend std::ostream& operator<< (std::ostream &out, const Kwadrat &val);
- public:
- Kwadrat(double a) : Prostokat(a, a) { };
- };
- class Okrag :public Elipsa {
- public:
- Okrag(double r) : Elipsa(r, r) {};
- double pole() {
- return Elipsa::a*Elipsa::b*3.14;
- }
- double obwod() {
- return 2 * Elipsa::a*3.14;
- }
- };
- std::ostream& operator<< (std::ostream &out, const Kwadrat &val) {
- out << val.a;
- return out;
- }
- int main(void) {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement