Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit2ab9124355fdc5ac6843cd4af84b927ee5a417bc (patch)
Author
 Angel Dimitriev <achi_d@abv.bg>
2021-06-03 11:46:21 -0400
Committer
 GitHub <noreply@github.com>
2021-06-03 11:46:21 -0400
Files734b37c5cb5578ac7062540168476db84d45c848
Object-oriented_programming_FMI-2ab9124355fdc5ac6843cd4af84b927ee5a417bc.tar
Object-oriented_programming_FMI-2ab9124355fdc5ac6843cd4af84b927ee5a417bc.tar.gz
Object-oriented_programming_FMI-2ab9124355fdc5ac6843cd4af84b927ee5a417bc.zip
Parent647290a45d8bc76754421259d757b7be6170459e (diff)
Update README.md
1 files changed, 15 insertions, 11 deletions
-rw-r--r--Sem. 14/README.md26
diff --git a/Sem. 14/README.md b/Sem. 14/README.md
index 646c390..7dc04fb 100644
--- a/Sem. 14/README.md
+++ b/Sem. 14/README.md
@@ -10,7 +10,8 @@ struct Fruit
virtual void printColor() const = 0;
virtual ~Fruit(){}
-}
+};
+
```c++
struct Apple
{
@@ -18,7 +19,7 @@ struct Apple
{
std::cout << "Red or green! "<<std::endl;
}
-}
+};
struct Orange
{
@@ -27,7 +28,8 @@ struct Orange
std::cout << "Orange! "<<std::endl;
}
-}
+};
+
struct Lemon
{
Lemon(size_t sourness) : sourness(sourness){}
@@ -37,7 +39,8 @@ struct Lemon
{
std::cout << "Yellow! "<<std::endl;
}
-}
+};
+
class FruitStore
{
private:
@@ -57,7 +60,7 @@ public:
void addApple();
void addOrange();
void addLemon(size_t sourness);
-}
+};
void FruitStore::addApple
{
@@ -91,15 +94,15 @@ void FruitStore::free()
За това дефинираме виртуална функция clone, която ще връща копие на обекта. Тази функция я разписваме във всеки от наследниците.
```c++
-```c++
+
struct Fruit
{
virtual void printColor() const = 0;
virtual ~Fruit(){}
virtual Fruit* clone() const = 0; //!
-}
-```c++
+};
+
struct Apple
{
void printColor() const override
@@ -111,7 +114,7 @@ struct Apple
return new Apple(*this);
}
-}
+};
struct Orange
{
@@ -124,7 +127,8 @@ struct Orange
{
return new Apple(*this);
}
-}
+};
+
struct Lemon
{
Lemon(size_t sourness) : sourness(sourness){}
@@ -138,7 +142,7 @@ struct Lemon
{
return new Lemon(*this);
}
-}
+};
```
От тук копирането става тривиално:
```c++