Array Functions using Template
Hello, I am having trouble with displaying my array. The error says that displayArray identifier is not found?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
string day[5] = {"monday", "Tue", "Wednesday", "Thursday", "Friday"};
char days [5][10] = {"Monday", "Tuesday", "wednesday", "Thurs", "Friday"};
displayArray(day, 5);
displayArray(days, 5);
}
template<class T>
void displayArray(T x[], int n)
{
for (int i = 0; i < n; i++)
{
cout << x[i] << endl;
}
}
|
Hi,
The compiler does things in the order it sees them .... That is a big clue to solve this problem.
declare function before use
Topic archived. No new replies allowed.