Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 12 / Example_polymorphism / main.cpp
diff options
context:
space:
mode:
Commit110481bee48bdb18f3d635cbc507aac1acc7c694 (patch)
Author
 angeld55 <angel_dimitriev@abv.bg>
2022-05-24 20:10:50 +0300
Committer
 angeld55 <angel_dimitriev@abv.bg>
2022-05-24 20:10:50 +0300
Filesbe2cdf7f8769afd0f456776871b16fe8868ae67b /Sem. 12/Example_polymorphism/main.cpp
Object-oriented_programming_FMI-110481bee48bdb18f3d635cbc507aac1acc7c694.tar
Object-oriented_programming_FMI-110481bee48bdb18f3d635cbc507aac1acc7c694.tar.gz
Object-oriented_programming_FMI-110481bee48bdb18f3d635cbc507aac1acc7c694.zip
Parentc1a310e69933035fb385f52275e9b80cdad695fc (diff)
added shapes collection
1 files changed, 26 insertions, 1 deletions
-rw-r--r--Sem. 12/Example_polymorphism/main.cpp27
diff --git a/Sem. 12/Example_polymorphism/main.cpp b/Sem. 12/Example_polymorphism/main.cpp
index 89a5082..5d7fc69 100644
--- a/Sem. 12/Example_polymorphism/main.cpp
+++ b/Sem. 12/Example_polymorphism/main.cpp
@@ -17,12 +17,33 @@ void printPers(const Shape* const * shapes, size_t shapesCount)
cout << shapes[i]->getPer() << endl;
}
+void checkPointIn(const Shape* const* shapes, size_t shapesCount, int x, int y)
+{
+ for (int i = 0; i < shapesCount; i++)
+ cout << shapes[i]->isPointIn(x,y) << endl;
+}
+
void freeCollection(Shape** shapes, size_t shapesCount)
{
for (int i = 0; i < shapesCount; i++)
delete shapes[i];
delete[] shapes;
}
+
+struct A
+{
+ virtual void f() const
+ {
+ ;
+ }
+};
+struct B : public A
+{
+ void f() const final
+ {
+
+ }
+};
int main()
{
Shape** arr = new Shape*[4];
@@ -33,9 +54,13 @@ int main()
arr[3] = new Triangle(1, 1, 2, 2, 3, 3);
printAreas(arr, 4);
+ std::cout << endl;
printPers(arr, 4);
+ std::cout << endl;
+
+ checkPointIn(arr, 4, 3, 3);
+
freeCollection(arr, 4);
-
} \ No newline at end of file