lab22 - Lab 22 Source File: Input: Output: Value:...

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

View Full Document Right Arrow Icon
Lab 22 Due Date: Wednesday, October 12, 2011 Source File: ~/2305/lab22.C Input: under control of main function Output: under control of main function Value: 2 Write a template function whose prototype is given by 1 template<typename T> 2 int NumUnique(const T *array, int n); The function returns the number of unique elements in the range [array, array + n) . A main function for testing your function is shown in Figure 1. The expected output from executing this code is shown in Figure 2. To use the Makefile as distributed in class, add a target of lab22main to targets1srcfile . 1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 6 // template function prototype 7 template<typename T> 8 int NumUnique(const T *array, int n); 9 10 #include "lab22.C" 11 12 template<typename T> 13 void PrintArray(const T *array, int count) 14 { 15 const T *ptr; 16 const T *const endPtr = array + count; 17 18 for (ptr = array; ptr < endPtr; ptr++) 19 cout << *ptr << " "; 20 21 cout << endl; 22
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 10/13/2011 for the course CS 2305 taught by Professor Motl,m during the Fall '08 term at Angelo State.

Page1 / 2

lab22 - Lab 22 Source File: Input: Output: Value:...

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