Show the proper way to call your swap function such

This preview shows page 3 - 6 out of 9 pages.

swaps the values pointed to by them. Show the proper way to call your swap function such that the printf statements print what the comments indicate: /* Fill in parameter list first */ void swap ( ) { /* your code goes here */ } int main(void) { int a = 3; int b = 4; /* fill in arguments here */ swap ( ); printf("a is now %d\n", a); // should print a is now 4 printf("b is now %d\n", b); // should print b is now 3 return 0; } 3
Image of page 3

Subscribe to view the full document.

Question 2: Constructors/Operator Overloading Part A (3 points): Copy constructors and the assignment operator (=) are similar. Copy constructors, however, are used only in specific circumstances: list the three situations in which copy constructors are used: Part B (6 points): What is the appropraite signature for the copy constructor for a class called Foo? Part C (6 points): What is the appropriate signature for the assignment operator in the class called Foo (to allow assignment of one Foo to another)? Part D (5 points): There is an important difference between how dynamically dispatched functions behave during object construction in C++ and Java. Explain what this is and how it occurs. 4
Image of page 4
Question 3: Templates Part A (10 points): Write the function findMin which is templated over the type of item it processes. The findMin function should take a vector (i.e. the STL vector) of the
Image of page 5

Subscribe to view the full document.

Image of page 6
You've reached the end of this preview.
  • Fall '08
  • hershman

{[ snackBarMessage ]}

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