Getter function that won't crash when object not found
<p>I have a class that contains a member variable which is a list of custom objects. I am trying to write a getter function which looks through this list trying to find one with the provided name. I would like to return said object by constant reference if found, or just output "Object with name "name" not found." otherwise, without crashing my program. Any ideas? I'm thinking I could make another function that simply returns a boolean if a matching object exists, and calling that first. If it returns true, then get the given item. However, this is inefficient, and I would like to do better.</p>
