In this lab, we will work on Template
and Inheritance
through exercises.
- In your prior homework and lab assignments, where have you used templates before?
- Implement template functions for (1) summing of two numbers (or objects) and (2) choosing the max value between two numbers.
- Write a test case with a different type of numbers in main().
- Create a new struct of your choice, and show that it could be passed as arguments into the Template functions you created.
- Implement a function,
area()
, inRectangle
class, and discuss it with your partner. - Implement another class,
Triangle
, derived fromPolygon
. and write the similar test code in main(). - Insert code that prints out "[className]::constructor()" in both the Polygon and subclass constructors. Which is called first? Discuss about it with your partner.