Topical Information

This lab will help you practice with vectors and templates.

Program Information

Write a function to remove all duplicates from a vector sent as its sole argument.

Since that specification doesn't specify what type of data is present, make sure your function can run with any [reasonable] type as the vector's base type.

Of course, you'll need to write a little driver program to make sure your function is working properly...

Thought Provoking Questions

  1. What types of elements can your function's vector argument hold? (i.e. What's the vector's base type?)
  2. How can you go through all of the elements in a vector? Do you know how long a vector is? How does one access the content of an individual position? What is the data type of a position — not the content of the position, but the position itself! — ?
  3. How can you detect that an element is repeated? (i.e. "is the same as one 'already' seen?") (*nudge* "is the same as the one I'm examining right now?") (*wink* "while I'm looking at a certain one, I notice that one of those following is the same...") (*shrug* *waves and points*)
  4. How can you remove a found repeat? Do you have to code removal of an element from a vector or is there already a function for this action?
  5. Would functions help to make this program more manageable? If so, describe your design for each. If not, why the heck did we learn about those darn things?!? *(&^&%^%$ Jason! *(^&*^%$%$^ C++! *(&)^&% programming!

This assignment is (Level 2.5).

Options