Last active
January 9, 2018 19:48
-
-
Save krvajal/39d9d7b010d7d2e9bb5692b3c331c267 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Requirement: print the area of the given shape | |
void print_area(const Shape &shape) | |
{ | |
std::cout << shape.get_area() << std::endl; | |
} | |
int main(){ | |
std::vector<std::unique_ptr<Shape>> shapes; | |
shapes.push_back(std::make_unique<Circle>(10)); | |
shapes.push_back(std::make_unique<Circle>(11.0)); | |
shapes.push_back(std::make_unique<Rectangle>(10.0, 20.0)); | |
shapes.push_back(std::make_unique<Rectangle>(1.0, 0.5)); | |
for (auto &s : shapes) | |
{ | |
print_area(*s); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment