c17f00t2 - CSc 17 Test 2 20 November 2000 >SUGGESTED...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSc 17 Test 2 20 November 2000 >>>>>>>>>>>>>>>>>>>>>>>SUGGESTED ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<<<<<, 1. (20 pts) Assume the class LinkList below. Write a member function of LinkList called same() which returns true if and only if two linked lists have the same data in the same order. Given the declaration LinkList a,b;, the call to same() would be a.same(b); (or b.same(a);). (You need not provide the prototype for same()) class LinkList{ private: class Link{ public: Link(); Link(int x); int key; Link *next; }; Link *root; public: ... ... }; Link *one,*two; one=root; two=list.root; one=one->next; two=two->next; } return one==NULL & two==NULL; } 2. (25 pts) For the class X below overload the operators "+" and "<<". When we have the declaration X a,b; a+b should return an instance of X whose data member x contains the sum of the x's of a and b, and if a.x=4, cout<<a; should display a in the form "X(4)".
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/09/2008 for the course CSE 17 taught by Professor Varies during the Spring '08 term at Lehigh University .

Page1 / 3

c17f00t2 - CSc 17 Test 2 20 November 2000 >SUGGESTED...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online