BASE:
1. write the output.
2. With the function Template:
What is the template function prototype invoked by Show<10>(“abcdefghijklmn”)? What’s the output?
- the program’s output is not right, please correct the following program with right semantics:
4.write the output of the following code.
5.Case:
Please write the output:
6.Which of the following templates are illegal? Why?
(1)
(2)
(3)
(4)
(5)
7.correct the class CList declaration (No need to implement the members.)
8.write the output for overload class template
ADVANCED:
1.Write a class template CVar which has following methods:
And other necessary members.
- Write some global function template:
You can try to comment CVar class operator +/- to test whether your global function is enable.
- Write a specialized template class CVar<char*> and CVar.
- Write a template function my_sort as following:
EXPLORATION:
1. Design a template queue class and implement the following members:
(1) method void add(Type elem). //add an element to tail.
(2) method Type remove(). //remove element from head, and return the element.
(3) method Type head(). //return the head value of queue.
(4) method void clear(). //clear all queue.
(5) method bool is_empty(). //indicate whether the queue is empty.
(6) method size_t count(). //return the count.
(7) nested class Iterator to traverse the queue.
(8) method operator+=(Type elem). //The same to add();
(9) method operator–(). //The same to remove();
(10) method Iterator begin(). //Return the begin of the queue.
(11) method Iterator end(). //Return the end of the queue.
Besides, define an global overload operator:
to directly output all the values of queue item.
the following is the test of your queue:
The ourput is:
Removed : 5 Current Head : 10
There are 9 queue items: < 10 15 20 25 30 35 40 45 50 >
10 15 20 25 30 35 40 45 50
There are 0 queue items: < >
2.design a class template CHash which algorithm is besed on buckets:
FUN:
1.Write the output of the following code.
2.The following is a smart list. Please add other necessary implements to make it work.