/lab9

eecs230 lab9

Primary LanguageC++

EECS230 Lab9

In this lab, we will work on Template and Inheritance through exercises.

Exercises

Template

  1. In your prior homework and lab assignments, where have you used templates before?
  2. Implement template functions for (1) summing of two numbers (or objects) and (2) choosing the max value between two numbers.
  3. Write a test case with a different type of numbers in main().
  4. Create a new struct of your choice, and show that it could be passed as arguments into the Template functions you created.

Inheritance

  1. Implement a function, area(), in Rectangle class, and discuss it with your partner.
  2. Implement another class, Triangle, derived from Polygon. and write the similar test code in main().
  3. Insert code that prints out "[className]::constructor()" in both the Polygon and subclass constructors. Which is called first? Discuss about it with your partner.