Hi, anyone can tell me what's wrong with my code? the only part has problem is the function overload << operator, any help is welcome.
#include <iostream>
using namespace std;
template <typename T, int SIZE>
class array
{
T data_[SIZE];
array (const array& other);
const array& operator = (const array& other);
public:
array(){};
T& operator[](int i) {return data_[i];}
const int getSize() const{return SIZE;};
const T& get_elem (int i) const {return data_[i];}
void set_elem(int i, const T& value) {data_[i] = value;}
operator T*() {return data_;}
friend ostream& operator<< <T, SIZE>(ostream&, const array<T, SIZE>&);
};
ostream& operator<< <T, SIZE> (ostream& out, const array<T, SIZE>& ar)
{
out<<"< ";
for(int i=0;i<ar.getSize();i++)
out<<ar.get_elem(i)<<" ";
out<<" >";
return out;
}
int main(void)
{
array<int, 10> intArray;
for(int i=0;i<10;i++) intArray.set_elem(i, i+100);
//std::cout<<" element 0: "<<intArray.get_elem(0)<<std::endl;
//int firstElem = intArray.get_elem(0);
//int* begin = intArray;
cout<<intArray;
}