E the stl vector of the given type it should return

This preview shows page 5 - 8 out of 9 pages.

function should take a vector (i.e. the STL vector) of the given type. It should return the smallest item in the vector by value. You may assume the vector passed in is non-empty. Hint: you should use an iterator. Part B (10 points): The function you wrote in part A uses the < operator, which is not defined on all types. Explain how the C++ compiler handles this. When/where would an error occur if you tried to use this function on a type for which < was not defined? 5
Image of page 5

Subscribe to view the full document.

Question 4: Object Layout For this question, use the following object layouts for objects of type Foo and Bar : <vtbl> <vtbl> int num1 int counter min inc max Objects of type Bar Objects of type Foo int num2 Part A (10 points) Class Baz is declared as follows: class Baz: public Foo, public Bar { int xyz; }; Draw the layout of an object of type Baz in the space below: 6
Image of page 6
Part B (5 points) Briefly explain what a vtable is and what is used for. Part C (5 points) Given the following declarations: class A {...} class B: public A {...} class C: public A {...} class D: public B, public C {...} How many A sub-objects does a D have? Suppose that this is not the behavior you desired, indicate what changes need to be made to the above declarations to get the other possible behavior.
Image of page 7

Subscribe to view the full document.

Image of page 8
  • Fall '08
  • hershman

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern