c109s03t2

c109s03t2 - CSE 109 Test 2 Wednesday 9 April 2003...

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

View Full Document Right Arrow Icon
CSE 109 Test 2 Wednesday 9 April 2003 <><><><><><><><><>SUGGESTED ANSWERS<><><><><><><><><>><><><><><> 1. An Association is a pair consisting of a "key" and a "value." Write the template class for Association so that the following code compiles and produces the output indicated. The class need have no other functionality. Association <int,double> a(2,2.7); Association <Word, Word> b("hope","esperanza"); a.setValue(2.3); cout<<x<<" "<<b<<endl; // displays: {2, 2.3} {hope, esperanza} ================================================================ #include <fstream.h> # template <class KEY, class VALUE> class Association {public: Association(const KEY &k,const VALUE &v); void setValue(const VALUE &v); template <class K, class V> friend ostream & operator <<(ostream &out,const Association & a); private: KEY key; VALUE value; }; } template <class KEY, class VALUE> :key(k),value(v){} template <class KEY, class VALUE>
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.

Page1 / 2

c109s03t2 - CSE 109 Test 2 Wednesday 9 April 2003...

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