c109f02t2 - CSE 109 Test 2 20 November 2002 >SUGGESTED...

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

View Full Document Right Arrow Icon
CSE 109 Test 2 20 November 2002 >>>>>>>>>>>>>>SUGGESTED ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<< 1. Given the class A below, write the declaration and definition (code) for B, a subclass of A so that the code below the first dashed line produces all four characters of the output below the second dashed line. class A {public: A(int x=0); int get(); //returns the value of data private: int data; }; --------------------------------------------------- B a(20); a.display(); --------------------------------------------------- [20] ===================================================== class B : public A {public: B(int x=0); void display(); }; } B::B(int x):A(x){} void B::display(){cout<<'['<<get()<<']';} 2. Assume you have a class HashTable of fixed size 2003 (which is prime), implemented with the data member int table[2003]; The table is meant to store social security numbers and is initialized with 0's. Write the prototype and definition of the HashTable member function "location" which returns -1 if some entry is not in the table and returns the index of an entry
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 109 taught by Professor Kay during the Spring '08 term at Lehigh University .

Page1 / 2

c109f02t2 - CSE 109 Test 2 20 November 2002 >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