lab20 - Lab 20 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 20 Due Date: Wednesday, October 5, 2011 Source File: ~/2305/lab20.C Input: under control of main function Output: under control of main function Value: 1 Write a template function whose prototype is given by 1 template<typename T> 2 const T *LinearSearch(const T *array, int n, T itemToFind); The function returns a pointer in the n -element array array to the Frst element whose value is equal to itemToFind . The function returns NULL if itemToFind is not an element of array . A main function for testing your function is shown in ±igure 1. The expected output from executing this code is shown in ±igure 2. To use the Makefile as distributed in class, add a target of lab20main to targets1srcfile . 1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 6 // template function prototype 7 template<typename T> 8 const T *LinearSearch(const T *array, int n, T itemToFind); 9 10 #include "lab20.C" 11 12 template<typename T> 13 void PrintArray(const T *array, int count) 14 { 15 const T *ptr;
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 / 3

lab20 - Lab 20 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