Practice 1The first task is to define a function object class Show, which displays an element specified as its argument.class Show should not inherit anything from any other class. Once you define class Show, write main() function to test it. You should be able to use Show function object like: Show<string> myShow; myShow("hello"); ... Show<double> myShowd; myShowd(45.89); Practice 2Next, task is to implement class Show as a subclass of unary_function struct. You can define Show as a struct or a class. Practice 3Now you have created Show function object to display an element. Your next task is to create an algorithmout(), which takes two iterators (first and last) and display each element using your Show function object. Practice 4Using the above out() algorithm, which uses your struct Show function object, do the following:
string strarray[] = {"a", "c", "l", "u", "w", "e", "c", "z", "b", "l", "o", "r"}; int size = sizeof strarray / sizeof(string);
|