I am getting error on ostream_iterator. I wanted to keep T as a template. But at that point it is giving error. Kindly help me.
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iterator>
using namespace std;
int main(void){
int arr[] = {2, 5, 7, 90, 70};
int *ptr = arr;
char* str = "mudit";
int n = sizeof(arr)/sizeof(arr[0]);
cout.write (str, 5);
cout << endl;
//printing the array in one line.
copy(arr,arr+n,template<class T> ostream_iterator<T>(cout, "\n")); //Getting
//error at this line.
//cout << copy(arr, arr+n) << endl;
int x = 7;
//cout << "Searching " << x << " position is at : " << search(arr, n,
sizeof(int), &x, compare) << endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire