V
Vespasian
I create an templated Array class. My constructor declaration is as
follows,
template<class X> Array<X>::Array(int s); // Constructor
I also have templated sorting function,
template<class X> void Quicksort(X values[], int first, int last);
I am getting the following compilation error,
error C2784: 'void Quicksort(X [],int,int)' : could not deduce
template argument for 'T1 []' from 'Array<X>'
with
[
X=std::string
]
My dirver code,
// Read in an array of strings
cout << "How many words? ";
cin >> num;
Array<string> b(num);
cout << "Enter the " << num << " words below:\n";
for (int i=0; i<num ; i++) cin >> b;
// Copy the original array and sort it using Quicksort
Array<string> bq(b);
Quicksort(bq, 0, num-1);
cout << "\nElements sorted using quicksort:\n";
for (int i=0; i<num ; i++) cout << bq<< " ";
Don't know what's wrong. Any help is appreciated,
TIA,
Ves
follows,
template<class X> Array<X>::Array(int s); // Constructor
I also have templated sorting function,
template<class X> void Quicksort(X values[], int first, int last);
I am getting the following compilation error,
error C2784: 'void Quicksort(X [],int,int)' : could not deduce
template argument for 'T1 []' from 'Array<X>'
with
[
X=std::string
]
My dirver code,
// Read in an array of strings
cout << "How many words? ";
cin >> num;
Array<string> b(num);
cout << "Enter the " << num << " words below:\n";
for (int i=0; i<num ; i++) cin >> b;
// Copy the original array and sort it using Quicksort
Array<string> bq(b);
Quicksort(bq, 0, num-1);
cout << "\nElements sorted using quicksort:\n";
for (int i=0; i<num ; i++) cout << bq<< " ";
Don't know what's wrong. Any help is appreciated,
TIA,
Ves