|
-
April 13th, 2012, 08:49 PM
#1
function template
Write a function template contains that accepts an array of the parameterized type, the number of elements in the array (an integer), and a value of the parameterized type, and returns true if the value is in the array and false otherwise.
template<class T>
bool contains(T a[], int k, T p)
{
bool stat = false;
for(int i=0; i < k; i++)
{
if(a[i] == p)
{
stat = true;
}
}
return stat;
}
saying compiler error...help please
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|