Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- class Figura
- {
- protected:
- string descriere;
- public:
- virtual void deseneaza() = 0;
- };
- class Linie : public Figura
- {
- protected:
- int x1, x2;
- public:
- void deseneaza() {
- descriere = "Linie orziontala";
- int i;
- for (i = 1; i < x1; i++)cout << " ";
- for (i = x1; i <= x2; i++)
- cout << "*";
- cout << "\n";
- }
- Linie(int x1, int x2) {
- this->x1 = x1;
- this->x2 = x2;
- }
- };
- class Dreptunghi: public Linie
- {
- private:
- int y;
- public:
- void deseneaza() {
- descriere = "un dreptunghi";
- cout << "Aceasta este " << descriere.c_str() << "\n";
- int i = 0;
- while (i < y) {
- Linie::deseneaza();
- i++;
- }
- }
- Dreptunghi(int x1, int x2, int y) : Linie(x1, x2) {
- this->y = y;
- }
- };
- int main() {
- Figura *pFig;
- pFig = new Linie(10, 20);
- pFig->deseneaza();
- delete pFig;
- pFig = new Dreptunghi(10, 49, 10);
- pFig->deseneaza();
- delete pFig;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement