-2

I have to create a dynamically allocated vector of objects from the Resistor class, which only has two private variables: resistance and tolerance. After that, a function must be created in order to search the vector for those objects that have resistance and tolerance equal to the values passed in the function's argument.

After searching for a while, I have no idea how to implement this. Any thoughts?

Flo
  • 69
  • 2
  • 6
  • What do you expect the output of this function to be? Another container with the matching elements? A container with the indices of those elements in the first container? A container with iterators or pointers to those elements? – juanchopanza Jan 27 '13 at 10:41

1 Answers1

1
  1. Implement the comparison operator operator==(const Resistor&) of your Resistor class.
  2. Use std::find to search the vector for the data by supplying a new Resistor instance created from the function arguments.

See http://www.cplusplus.com/reference/algorithm/find/

theV0ID
  • 4,172
  • 9
  • 35
  • 56