Skip to content

Commit fecc3a9

Browse files
committed
Improve printouts in polymorphism exercise.
Instead of describing which method is being called, we directly print the names of the functions.
1 parent 68a7011 commit fecc3a9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

code/polymorphism/Polygons.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Polygon::Polygon(int n, float radius) : m_nbSides(n), m_radius(radius) {};
66

77
float Polygon::computePerimeter() const {
8-
std::cout << "Generic computePerimeter for polygons\n";
8+
std::cout << "Polygon::computePerimeter is being called\n";
99
return 2*m_nbSides*std::sin(static_cast<float>(M_PI)/m_nbSides)*m_radius;
1010
}
1111

@@ -14,6 +14,6 @@ Pentagon::Pentagon(float radius) : Polygon(5, radius) {}
1414
Hexagon::Hexagon(float radius) : Polygon(6, radius) {}
1515

1616
float Hexagon::computePerimeter() const {
17-
std::cout << "Optimized computePerimeter for hexagons\n";
17+
std::cout << "Hexagon::computePerimeter is being called\n";
1818
return 6 * m_radius;
1919
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy